Search in sources :

Example 1 with AuthoritiesConfiguration

use of se.inera.intyg.infra.security.authorities.AuthoritiesConfiguration in project webcert by sklintyg.

the class SecurityConfigurationLoaderTest method loadConfigurationAndAssertTypeOfObjects.

@Test
public void loadConfigurationAndAssertTypeOfObjects() {
    AuthoritiesConfiguration configuration = loader.getAuthoritiesConfiguration();
    assertEquals(4, configuration.getRequestOrigins().size());
    assertEquals(9, configuration.getPrivileges().size());
    assertEquals(4, configuration.getRoles().size());
    assertEquals(2, configuration.getTitles().size());
    assertEquals(4, configuration.getTitleCodes().size());
    // Assert that lists are of specific types
    try {
        List<RequestOrigin> requestOrigins = (List<RequestOrigin>) configuration.getRequestOrigins();
        List<Privilege> privileges = (List<Privilege>) configuration.getPrivileges();
        List<Role> roles = (List<Role>) configuration.getRoles();
        List<Title> titles = (List<Title>) configuration.getTitles();
        List<TitleCode> titleCodes = (List<TitleCode>) configuration.getTitleCodes();
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
Also used : RequestOrigin(se.inera.intyg.infra.security.common.model.RequestOrigin) Title(se.inera.intyg.infra.security.common.model.Title) AuthoritiesConfiguration(se.inera.intyg.infra.security.authorities.AuthoritiesConfiguration) IOException(java.io.IOException) Role(se.inera.intyg.infra.security.common.model.Role) TitleCode(se.inera.intyg.infra.security.common.model.TitleCode) List(java.util.List) Privilege(se.inera.intyg.infra.security.common.model.Privilege) Test(org.junit.Test)

Example 2 with AuthoritiesConfiguration

use of se.inera.intyg.infra.security.authorities.AuthoritiesConfiguration in project webcert by sklintyg.

the class SecurityConfigurationLoaderTest method loadConfigurationAndAssertString.

// @Test    // Temporarily disabling this test, it acts weird on OpenShift.
public void loadConfigurationAndAssertString() {
    AuthoritiesConfiguration configuration = loader.getAuthoritiesConfiguration();
    String actual = configuration.toString().replaceAll("\\s", "").trim();
    String expected = "";
    try {
        Resource resource = getResource(authoritiesConfigurationOutputFile);
        expected = new String(Files.readAllBytes(Paths.get(resource.getURI()))).replaceAll("\\s", "").trim();
    } catch (IOException e) {
        fail(e.getMessage());
    }
    assertEquals(expected, actual);
}
Also used : Resource(org.springframework.core.io.Resource) AuthoritiesConfiguration(se.inera.intyg.infra.security.authorities.AuthoritiesConfiguration) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)2 AuthoritiesConfiguration (se.inera.intyg.infra.security.authorities.AuthoritiesConfiguration)2 List (java.util.List)1 Test (org.junit.Test)1 Resource (org.springframework.core.io.Resource)1 Privilege (se.inera.intyg.infra.security.common.model.Privilege)1 RequestOrigin (se.inera.intyg.infra.security.common.model.RequestOrigin)1 Role (se.inera.intyg.infra.security.common.model.Role)1 Title (se.inera.intyg.infra.security.common.model.Title)1 TitleCode (se.inera.intyg.infra.security.common.model.TitleCode)1