diff --git a/app/common/src/test/java/stirling/software/common/model/ApplicationPropertiesSaml2HttpTest.java b/app/common/src/test/java/stirling/software/common/model/ApplicationPropertiesSaml2HttpTest.java index de25c20f88..a84d0c9205 100644 --- a/app/common/src/test/java/stirling/software/common/model/ApplicationPropertiesSaml2HttpTest.java +++ b/app/common/src/test/java/stirling/software/common/model/ApplicationPropertiesSaml2HttpTest.java @@ -31,9 +31,9 @@ class ApplicationPropertiesSaml2HttpTest { String url = server.url("/meta").toString(); var s = new ApplicationProperties.Security.SAML2(); - s.setIdpMetadataUri(url); + s.setMetadataUri(url); - try (InputStream in = s.getIdpMetadataUri()) { + try (InputStream in = s.getMetadataUriAsStream()) { String body = new String(in.readAllBytes(), StandardCharsets.UTF_8); assertTrue(body.contains("EntityDescriptor")); } @@ -44,9 +44,9 @@ class ApplicationPropertiesSaml2HttpTest { void idpMetadataUri_invalidUri_triggers_catch_and_throwsIOException() { // Ungültige URI -> new URI(...) wirft URISyntaxException -> catch -> IOException var s = new ApplicationProperties.Security.SAML2(); - s.setIdpMetadataUri("http:##invalid uri"); // absichtlich kaputt (Leerzeichen + ##) + s.setMetadataUri("http:##invalid uri"); // absichtlich kaputt (Leerzeichen + ##) - assertThrows(IOException.class, s::getIdpMetadataUri); + assertThrows(IOException.class, s::getMetadataUriAsStream); } @Test @@ -57,8 +57,8 @@ class ApplicationPropertiesSaml2HttpTest { Path tmp = Files.createTempFile("spdf-spcert-", ".crt"); Files.writeString(tmp, "CERT"); - s.setSpCert(tmp.toString()); - Resource r = s.getSpCert(); + s.getSp().setCert(tmp.toString()); + Resource r = s.getSp().getCertResource(); assertNotNull(r); assertInstanceOf(FileSystemResource.class, r, "Expected FileSystemResource for FS path"); @@ -71,8 +71,8 @@ class ApplicationPropertiesSaml2HttpTest { // bewusst nicht existierender Pfad -> else-Zweig wird trotzdem genommen String missing = "/this/path/does/not/exist/idp.crt"; - s.setIdpCert(missing); - Resource r = s.getIdpCert(); + s.getProvider().setCert(missing); + Resource r = s.getProvider().getCertResource(); assertNotNull(r); assertInstanceOf(FileSystemResource.class, r, "Expected FileSystemResource for FS path"); diff --git a/app/common/src/test/java/stirling/software/common/model/ApplicationPropertiesSaml2ResourceTest.java b/app/common/src/test/java/stirling/software/common/model/ApplicationPropertiesSaml2ResourceTest.java index efc2665614..74ec598224 100644 --- a/app/common/src/test/java/stirling/software/common/model/ApplicationPropertiesSaml2ResourceTest.java +++ b/app/common/src/test/java/stirling/software/common/model/ApplicationPropertiesSaml2ResourceTest.java @@ -15,9 +15,9 @@ class ApplicationPropertiesSaml2ResourceTest { @Test void idpMetadataUri_classpath_is_resolved() throws Exception { var s = new ApplicationProperties.Security.SAML2(); - s.setIdpMetadataUri("classpath:saml/dummy.txt"); + s.setMetadataUri("classpath:saml/dummy.txt"); - try (InputStream in = s.getIdpMetadataUri()) { + try (InputStream in = s.getMetadataUriAsStream()) { assertNotNull(in, "Classpath InputStream should not be null"); String txt = new String(in.readAllBytes(), StandardCharsets.UTF_8); assertTrue(txt.contains("ok")); @@ -28,27 +28,26 @@ class ApplicationPropertiesSaml2ResourceTest { void spCert_idpCert_privateKey_null_classpath_and_filesystem() throws Exception { var s = new ApplicationProperties.Security.SAML2(); - s.setSpCert(null); - s.setIdpCert(null); - s.setPrivateKey(null); - assertNull(s.getSpCert()); - assertNull(s.getIdpCert()); - assertNull(s.getPrivateKey()); + // Test null values via the nested structure + assertNull(s.getSp().getCertResource()); + assertNull(s.getProvider().getCertResource()); + assertNull(s.getSp().getPrivateKeyResource()); - s.setSpCert("classpath:saml/dummy.txt"); - s.setIdpCert("classpath:saml/dummy.txt"); - s.setPrivateKey("classpath:saml/dummy.txt"); - Resource sp = s.getSpCert(); - Resource idp = s.getIdpCert(); - Resource pk = s.getPrivateKey(); + // Set classpath resources via the nested structure + s.getSp().setCert("classpath:saml/dummy.txt"); + s.getProvider().setCert("classpath:saml/dummy.txt"); + s.getSp().setPrivateKey("classpath:saml/dummy.txt"); + Resource sp = s.getSp().getCertResource(); + Resource idp = s.getProvider().getCertResource(); + Resource pk = s.getSp().getPrivateKeyResource(); assertTrue(sp.exists()); assertTrue(idp.exists()); assertTrue(pk.exists()); Path tmp = Files.createTempFile("spdf-key-", ".pem"); Files.writeString(tmp, "KEY"); - s.setPrivateKey(tmp.toString()); - Resource pkFs = s.getPrivateKey(); + s.getSp().setPrivateKey(tmp.toString()); + Resource pkFs = s.getSp().getPrivateKeyResource(); assertNotNull(pkFs); assertTrue(pkFs.exists()); } diff --git a/app/proprietary/src/test/java/stirling/software/proprietary/security/CustomLogoutSuccessHandlerTest.java b/app/proprietary/src/test/java/stirling/software/proprietary/security/CustomLogoutSuccessHandlerTest.java index 2fd7ba7a18..96d9b2809e 100644 --- a/app/proprietary/src/test/java/stirling/software/proprietary/security/CustomLogoutSuccessHandlerTest.java +++ b/app/proprietary/src/test/java/stirling/software/proprietary/security/CustomLogoutSuccessHandlerTest.java @@ -27,6 +27,8 @@ class CustomLogoutSuccessHandlerTest { @Mock private JwtServiceInterface jwtService; + @Mock private ApplicationProperties.Security.SAML2 saml2; + private CustomLogoutSuccessHandler customLogoutSuccessHandler; @BeforeEach @@ -41,6 +43,8 @@ class CustomLogoutSuccessHandlerTest { String logoutPath = "/login?logout=true"; when(response.isCommitted()).thenReturn(false); + when(securityProperties.getSaml2()).thenReturn(saml2); + when(saml2.getEnableSingleLogout()).thenReturn(false); when(request.getContextPath()).thenReturn(""); when(response.encodeRedirectURL(logoutPath)).thenReturn(logoutPath); @@ -56,6 +60,8 @@ class CustomLogoutSuccessHandlerTest { String logoutPath = "/login?logout=true"; when(response.isCommitted()).thenReturn(false); + when(securityProperties.getSaml2()).thenReturn(saml2); + when(saml2.getEnableSingleLogout()).thenReturn(false); when(request.getContextPath()).thenReturn(""); when(response.encodeRedirectURL(logoutPath)).thenReturn(logoutPath); diff --git a/frontend/src/proprietary/auth/springAuthClient.test.ts b/frontend/src/proprietary/auth/springAuthClient.test.ts index 6b20e22a69..751bb9ce99 100644 --- a/frontend/src/proprietary/auth/springAuthClient.test.ts +++ b/frontend/src/proprietary/auth/springAuthClient.test.ts @@ -252,7 +252,8 @@ describe('SpringAuthClient', () => { describe('signOut', () => { let mockForm: { method: string; action: string; style: { display: string }; submit: ReturnType }; - let appendChildSpy: ReturnType; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + let appendChildSpy: any; beforeEach(() => { // Mock form creation and submission @@ -263,7 +264,7 @@ describe('SpringAuthClient', () => { submit: vi.fn(), }; vi.spyOn(document, 'createElement').mockReturnValue(mockForm as unknown as HTMLElement); - appendChildSpy = vi.spyOn(document.body, 'appendChild').mockImplementation(() => mockForm as unknown as HTMLFormElement); + appendChildSpy = vi.spyOn(document.body, 'appendChild').mockImplementation((node) => node); }); afterEach(() => { diff --git a/frontend/src/proprietary/routes/AuthCallback.test.tsx b/frontend/src/proprietary/routes/AuthCallback.test.tsx index f1646331b0..66f3f08977 100644 --- a/frontend/src/proprietary/routes/AuthCallback.test.tsx +++ b/frontend/src/proprietary/routes/AuthCallback.test.tsx @@ -1,5 +1,5 @@ import { describe, it, expect, beforeEach, vi, afterEach } from 'vitest'; -import { render, waitFor, cleanup } from '@testing-library/react'; +import { render, cleanup } from '@testing-library/react'; import { BrowserRouter } from 'react-router-dom'; import AuthCallback from '@app/routes/AuthCallback';