Search in sources :

Example 1 with GoogleAuthenticatorMultifactorProperties

use of org.apereo.cas.configuration.model.support.mfa.gauth.GoogleAuthenticatorMultifactorProperties in project cas by apereo.

the class RestGoogleAuthenticatorTokenCredentialRepositoryTests method verifyFailOps.

@Test
public void verifyFailOps() throws Exception {
    val props = new GoogleAuthenticatorMultifactorProperties();
    props.getRest().setUrl("http://localhost:8551");
    val repo = new RestGoogleAuthenticatorTokenCredentialRepository(googleAuthenticatorInstance, props, CipherExecutor.noOpOfStringToString());
    val entity = MAPPER.writeValueAsString(List.of("----"));
    try (val webServer = new MockWebServer(8551, new ByteArrayResource(entity.getBytes(UTF_8), "Output"), OK)) {
        webServer.start();
        assertNull(repo.get("casuser", 1));
        assertNull(repo.get(1));
        assertNull(repo.get("casuser"));
        assertEquals(0, repo.count());
        assertEquals(0, repo.count("casuser"));
        assertNull(repo.update(null));
    }
}
Also used : lombok.val(lombok.val) GoogleAuthenticatorMultifactorProperties(org.apereo.cas.configuration.model.support.mfa.gauth.GoogleAuthenticatorMultifactorProperties) MockWebServer(org.apereo.cas.util.MockWebServer) ByteArrayResource(org.springframework.core.io.ByteArrayResource) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with GoogleAuthenticatorMultifactorProperties

use of org.apereo.cas.configuration.model.support.mfa.gauth.GoogleAuthenticatorMultifactorProperties in project cas by apereo.

the class RestGoogleAuthenticatorTokenCredentialRepositoryTests method verifyLoad.

@Test
public void verifyLoad() throws Exception {
    val props = new GoogleAuthenticatorMultifactorProperties();
    props.getRest().setUrl("http://localhost:8551");
    val repo = new RestGoogleAuthenticatorTokenCredentialRepository(googleAuthenticatorInstance, props, CipherExecutor.noOpOfStringToString());
    val account = repo.create(UUID.randomUUID().toString());
    val entity = MAPPER.writeValueAsString(CollectionUtils.wrapArrayList(account));
    try (val webServer = new MockWebServer(8551, new ByteArrayResource(entity.getBytes(UTF_8), "Output"), OK)) {
        webServer.start();
        assertFalse(repo.load().isEmpty());
    }
}
Also used : lombok.val(lombok.val) GoogleAuthenticatorMultifactorProperties(org.apereo.cas.configuration.model.support.mfa.gauth.GoogleAuthenticatorMultifactorProperties) MockWebServer(org.apereo.cas.util.MockWebServer) ByteArrayResource(org.springframework.core.io.ByteArrayResource) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with GoogleAuthenticatorMultifactorProperties

use of org.apereo.cas.configuration.model.support.mfa.gauth.GoogleAuthenticatorMultifactorProperties in project cas by apereo.

the class RestGoogleAuthenticatorTokenCredentialRepositoryTests method verifyGetById.

@Test
public void verifyGetById() throws Exception {
    val props = new GoogleAuthenticatorMultifactorProperties();
    props.getRest().setUrl("http://localhost:8552");
    val repo = new RestGoogleAuthenticatorTokenCredentialRepository(googleAuthenticatorInstance, props, CipherExecutor.noOpOfStringToString());
    val account = repo.create(UUID.randomUUID().toString());
    val entity = MAPPER.writeValueAsString(account);
    try (val webServer = new MockWebServer(8552, new ByteArrayResource(entity.getBytes(UTF_8), "Results"), OK)) {
        webServer.start();
        assertNotNull(repo.get(account.getId()));
    }
}
Also used : lombok.val(lombok.val) GoogleAuthenticatorMultifactorProperties(org.apereo.cas.configuration.model.support.mfa.gauth.GoogleAuthenticatorMultifactorProperties) MockWebServer(org.apereo.cas.util.MockWebServer) ByteArrayResource(org.springframework.core.io.ByteArrayResource) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with GoogleAuthenticatorMultifactorProperties

use of org.apereo.cas.configuration.model.support.mfa.gauth.GoogleAuthenticatorMultifactorProperties in project cas by apereo.

the class RestGoogleAuthenticatorTokenCredentialRepositoryTests method verifyGet.

@Test
public void verifyGet() throws Exception {
    val props = new GoogleAuthenticatorMultifactorProperties();
    props.getRest().setUrl("http://localhost:8552");
    val repo = new RestGoogleAuthenticatorTokenCredentialRepository(googleAuthenticatorInstance, props, CipherExecutor.noOpOfStringToString());
    val account = repo.create(UUID.randomUUID().toString());
    val entity = MAPPER.writeValueAsString(CollectionUtils.wrapList(account));
    try (val webServer = new MockWebServer(8552, new ByteArrayResource(entity.getBytes(UTF_8), "Results"), OK)) {
        webServer.start();
        assertFalse(repo.get(account.getUsername()).isEmpty());
    }
}
Also used : lombok.val(lombok.val) GoogleAuthenticatorMultifactorProperties(org.apereo.cas.configuration.model.support.mfa.gauth.GoogleAuthenticatorMultifactorProperties) MockWebServer(org.apereo.cas.util.MockWebServer) ByteArrayResource(org.springframework.core.io.ByteArrayResource) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with GoogleAuthenticatorMultifactorProperties

use of org.apereo.cas.configuration.model.support.mfa.gauth.GoogleAuthenticatorMultifactorProperties in project cas by apereo.

the class RestGoogleAuthenticatorTokenCredentialRepositoryTests method verifyCount.

@Test
public void verifyCount() {
    val props = new GoogleAuthenticatorMultifactorProperties();
    props.getRest().setUrl("http://localhost:8552");
    val repo = new RestGoogleAuthenticatorTokenCredentialRepository(googleAuthenticatorInstance, props, CipherExecutor.noOpOfStringToString());
    try (val webServer = new MockWebServer(8552, new ByteArrayResource("1".getBytes(UTF_8), "Output"), OK)) {
        webServer.start();
        assertEquals(1, repo.count());
    }
}
Also used : lombok.val(lombok.val) GoogleAuthenticatorMultifactorProperties(org.apereo.cas.configuration.model.support.mfa.gauth.GoogleAuthenticatorMultifactorProperties) MockWebServer(org.apereo.cas.util.MockWebServer) ByteArrayResource(org.springframework.core.io.ByteArrayResource) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

lombok.val (lombok.val)10 GoogleAuthenticatorMultifactorProperties (org.apereo.cas.configuration.model.support.mfa.gauth.GoogleAuthenticatorMultifactorProperties)10 MockWebServer (org.apereo.cas.util.MockWebServer)10 Test (org.junit.jupiter.api.Test)10 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)10 ByteArrayResource (org.springframework.core.io.ByteArrayResource)10 Executable (org.junit.jupiter.api.function.Executable)2