@@ -87,6 +87,36 @@ void testEmptyProjectID() throws Exception {
8787 });
8888 }
8989
90+ @ Test
91+ void testShortProjectID () throws Exception {
92+ // Project ID too short (< 28 characters)
93+ String shortProjectId = "P1234567890123456789012345" ;
94+ EnvironmentVariables env = new EnvironmentVariables (PROJECT_ID_ENV_VAR , shortProjectId );
95+ env .execute (() -> {
96+ Assertions .assertThatThrownBy (DescopeClient ::new )
97+ .isInstanceOf (ClientSetupException .class )
98+ .hasMessage ("Invalid project ID - must be over 27 characters long" );
99+ });
100+ }
101+
102+ @ Test
103+ void testProjectIDRegion () throws Exception {
104+ String invalidRegionProjectId = "Pus11456789012345678901234567" ;
105+ EnvironmentVariables env = new EnvironmentVariables (PROJECT_ID_ENV_VAR , invalidRegionProjectId );
106+ env .execute (() -> {
107+ DescopeClient descopeClient = new DescopeClient ();
108+ ApiProxy apiProxy = mock (ApiProxy .class );
109+ UserResponseDetails userResponseDetails = mock (UserResponseDetails .class );
110+ when (apiProxy .get (eq (new URI ("https://api.descope.com/v1/mgmt/user?loginId=test" )), any ()))
111+ .thenReturn (userResponseDetails );
112+ try (MockedStatic <ApiProxyBuilder > mockedApiProxyBuilder = mockStatic (ApiProxyBuilder .class )) {
113+ mockedApiProxyBuilder .when (() -> ApiProxyBuilder .buildProxy (any (), any ())).thenReturn (apiProxy );
114+ UserResponseDetails u = descopeClient .getManagementServices ().getUserService ().load ("test" );
115+ Assertions .assertThat (u ).isNotNull ();
116+ }
117+ });
118+ }
119+
90120 @ Test
91121 void testEmptyConfig () {
92122 Assertions .assertThatThrownBy (() -> new DescopeClient (null ))
0 commit comments