@@ -793,111 +793,16 @@ describe("MCPServerForm", () => {
793793 } ) ;
794794 } ) ;
795795
796- describe ( "OAuth Password Grant Validation" , ( ) => {
797- // Helper: open advanced settings, switch to OAuth auth, select password grant
798- const renderWithOAuthPassword = // pragma: allowlist secret
799- async ( ) => {
800- const user = userEvent . setup ( ) ;
801- renderWithRouter ( < MCPServerForm { ...defaultProps } /> ) ;
802- await user . click ( screen . getByRole ( "button" , { name : / A d v a n c e d s e t t i n g s / i } ) ) ;
803- await user . click ( screen . getByRole ( "radio" , { name : / O A u t h 2 \. 0 / i } ) ) ;
804- // Grant type defaults to client_credentials; switch to password
805- await user . click ( screen . getByRole ( "combobox" , { name : / G r a n t t y p e / i } ) ) ;
806- await user . click ( screen . getByRole ( "option" , { name : / R e s o u r c e o w n e r p a s s w o r d / i } ) ) ;
807- return user ;
808- } ;
809-
810- it ( "shows username and password fields when password grant is selected" , async ( ) => {
811- await renderWithOAuthPassword ( ) ;
812- expect ( screen . getByLabelText ( / U s e r n a m e / i) ) . toBeInTheDocument ( ) ;
813- expect ( screen . getByLabelText ( / ^ P a s s w o r d / i) ) . toBeInTheDocument ( ) ;
814- } ) ;
815-
816- it ( "disables the submit button when username is empty" , async ( ) => {
817- await renderWithOAuthPassword ( ) ;
818- fireEvent . change ( screen . getByLabelText ( / ^ N a m e / i) , { target : { value : "Test Server" } } ) ;
819- fireEvent . change ( screen . getByLabelText ( / ^ U R L / i) , {
820- target : { value : "http://localhost:3000" } ,
821- } ) ;
822- // Leave username empty, fill password
823- fireEvent . change ( screen . getByLabelText ( / ^ P a s s w o r d / i) , { target : { value : "secret" } } ) ;
824- expect ( screen . getByRole ( "button" , { name : / C o n n e c t s e r v e r / i } ) ) . toBeDisabled ( ) ;
825- } ) ;
826-
827- it ( "disables the submit button when password is empty" , async ( ) => {
828- await renderWithOAuthPassword ( ) ;
829- fireEvent . change ( screen . getByLabelText ( / ^ N a m e / i) , { target : { value : "Test Server" } } ) ;
830- fireEvent . change ( screen . getByLabelText ( / ^ U R L / i) , {
831- target : { value : "http://localhost:3000" } ,
832- } ) ;
833- fireEvent . change ( screen . getByLabelText ( / ^ U s e r n a m e / i) , {
834- target : { value : "service-account" } ,
835- } ) ;
836- // Leave password empty
837- expect ( screen . getByRole ( "button" , { name : / C o n n e c t s e r v e r / i } ) ) . toBeDisabled ( ) ;
838- } ) ;
839-
840- it ( "enables the submit button when both username and password are provided" , async ( ) => {
841- await renderWithOAuthPassword ( ) ;
842- fireEvent . change ( screen . getByLabelText ( / ^ N a m e / i) , { target : { value : "Test Server" } } ) ;
843- fireEvent . change ( screen . getByLabelText ( / ^ U R L / i) , {
844- target : { value : "http://localhost:3000" } ,
845- } ) ;
846- fireEvent . change ( screen . getByLabelText ( / ^ U s e r n a m e / i) , {
847- target : { value : "service-account" } ,
848- } ) ;
849- fireEvent . change ( screen . getByLabelText ( / ^ P a s s w o r d / i) , { target : { value : "secret" } } ) ;
850- expect ( screen . getByRole ( "button" , { name : / C o n n e c t s e r v e r / i } ) ) . not . toBeDisabled ( ) ;
851- } ) ;
852-
853- it ( "marks username input as aria-invalid when username error is present" , async ( ) => {
854- await renderWithOAuthPassword ( ) ;
855- fireEvent . change ( screen . getByLabelText ( / ^ N a m e / i) , { target : { value : "Test Server" } } ) ;
856- fireEvent . change ( screen . getByLabelText ( / ^ U R L / i) , {
857- target : { value : "http://localhost:3000" } ,
858- } ) ;
859- // Only fill password, leave username empty
860- fireEvent . change ( screen . getByLabelText ( / ^ P a s s w o r d / i) , { target : { value : "secret" } } ) ;
861-
862- // Expose the field without a value and attempt form submission
863- const form = document . querySelector ( "form" ) ! ;
864- fireEvent . submit ( form ) ;
865-
866- await waitFor ( ( ) => {
867- expect ( screen . getByLabelText ( / ^ U s e r n a m e / i) ) . toHaveAttribute ( "aria-invalid" , "true" ) ;
868- } ) ;
869- } ) ;
870-
871- it ( "marks password input as aria-invalid when password error is present" , async ( ) => {
872- await renderWithOAuthPassword ( ) ;
873- fireEvent . change ( screen . getByLabelText ( / ^ N a m e / i) , { target : { value : "Test Server" } } ) ;
874- fireEvent . change ( screen . getByLabelText ( / ^ U R L / i) , {
875- target : { value : "http://localhost:3000" } ,
876- } ) ;
877- fireEvent . change ( screen . getByLabelText ( / ^ U s e r n a m e / i) , {
878- target : { value : "service-account" } ,
879- } ) ;
880- // Leave password empty, submit the form
881- const form = document . querySelector ( "form" ) ! ;
882- fireEvent . submit ( form ) ;
883-
884- await waitFor ( ( ) => {
885- expect ( screen . getByLabelText ( / ^ P a s s w o r d / i) ) . toHaveAttribute ( "aria-invalid" , "true" ) ;
886- } ) ;
887- } ) ;
888-
889- it ( "shows inline error messages for both fields when both are empty" , async ( ) => {
890- await renderWithOAuthPassword ( ) ;
891- fireEvent . change ( screen . getByLabelText ( / ^ N a m e / i) , { target : { value : "Test Server" } } ) ;
892- fireEvent . change ( screen . getByLabelText ( / ^ U R L / i) , {
893- target : { value : "http://localhost:3000" } ,
894- } ) ;
895- fireEvent . submit ( document . querySelector ( "form" ) ! ) ;
896-
897- await waitFor ( ( ) => {
898- expect ( screen . getByText ( "Username is required for password grant" ) ) . toBeInTheDocument ( ) ;
899- expect ( screen . getByText ( "Password is required for password grant" ) ) . toBeInTheDocument ( ) ;
900- } ) ;
796+ describe ( "OAuth Password Grant" , ( ) => {
797+ it ( "does not offer the deprecated password grant for new servers" , async ( ) => {
798+ const user = userEvent . setup ( ) ;
799+ renderWithRouter ( < MCPServerForm { ...defaultProps } /> ) ;
800+ await user . click ( screen . getByRole ( "button" , { name : / A d v a n c e d s e t t i n g s / i } ) ) ;
801+ await user . click ( screen . getByRole ( "radio" , { name : / O A u t h 2 \. 0 / i } ) ) ;
802+ await user . click ( screen . getByRole ( "combobox" , { name : / G r a n t t y p e / i } ) ) ;
803+ expect (
804+ screen . queryByRole ( "option" , { name : / R e s o u r c e o w n e r p a s s w o r d / i } ) ,
805+ ) . not . toBeInTheDocument ( ) ;
901806 } ) ;
902807
903808 it ( "does not show password-grant errors when a different OAuth grant type is selected" , async ( ) => {
0 commit comments