Skip to content

Commit

Permalink
add LDAP cache test
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasjensen-brolstark committed Mar 26, 2024
1 parent b1ad7ec commit d06787c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ quarkus.security.ldap.identity-mapping.search-base-dn=ou=Users,dc=quarkus,dc=io

quarkus.security.ldap.identity-mapping.attribute-mappings."0".from=cn
quarkus.security.ldap.identity-mapping.attribute-mappings."0".filter=(member=uid={0},ou=Users,dc=quarkus,dc=io)
quarkus.security.ldap.identity-mapping.attribute-mappings."0".filter-base-dn=ou=Roles,dc=quarkus,dc=io
quarkus.security.ldap.identity-mapping.attribute-mappings."0".filter-base-dn=ou=Roles,dc=quarkus,dc=io

quarkus.security.ldap.cache.enabled=true
quarkus.security.ldap.cache.max-age=60s
quarkus.security.ldap.cache.size=10
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@

import org.junit.jupiter.api.Test;

import com.unboundid.ldap.listener.InMemoryDirectoryServer;
import com.unboundid.ldap.sdk.LDAPException;

import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;

@QuarkusTest
class ElytronSecurityLdapTest {

InMemoryDirectoryServer ldapServer;

@Test
void anonymous() {
RestAssured.given()
Expand Down Expand Up @@ -82,4 +87,26 @@ void admin_role_not_authorized() {
.then()
.statusCode(403);
}

@Test()
void standard_role_authenticated_cached() throws LDAPException {
RestAssured.given()
.redirects().follow(false)
.when()
.auth().preemptive().basic("standardUser", "standardUserPassword")
.get("/api/requiresStandardRole")
.then()
.statusCode(200);

ldapServer.shutDown(false);

RestAssured.given()
.redirects().follow(false)
.when()
.auth().preemptive().basic("standardUser", "standardUserPassword")
.get("/api/requiresStandardRole")
.then()
.statusCode(200);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,9 @@ public synchronized void stop() {
ldapServer = null;
}
}

@Override
public void inject(TestInjector testInjector) {
testInjector.injectIntoFields(ldapServer, new TestInjector.MatchesType(InMemoryDirectoryServer.class));
}
}

0 comments on commit d06787c

Please sign in to comment.