Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/zizmor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ jobs:
persist-credentials: false

- name: Run zizmor
uses: cerbos/actions/lint-actions@c19f023116079958e91290ea4af73e25296d7614 # main
uses: cerbos/actions/lint-actions@2f4fe1d07ce827af7fe5e70a35ec3fff72b734dc # main
24 changes: 14 additions & 10 deletions src/test/java/dev/cerbos/sdk/CerbosBlockingAdminClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,21 @@ class CerbosBlockingAdminClientTest extends CerbosClientTests {
private static final ObjectMapper YAML_MAPPER = new ObjectMapper(new YAMLFactory());
private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
@Container
private static final CerbosContainer cerbosContainer =
new CerbosContainer("dev")
.withClasspathResourceMapping("config", "/config", BindMode.READ_ONLY)
.withCommand("server", "--config=/config/admin-config.yaml")
.withLogConsumer(new Slf4jLogConsumer(LOG));
private static final CerbosContainer cerbosContainer = new CerbosContainer("dev")
.withClasspathResourceMapping("config", "/config", BindMode.READ_ONLY)
.withCommand("server", "--config=/config/admin-config.yaml")
.withLogConsumer(new Slf4jLogConsumer(LOG));
CerbosBlockingAdminClient adminClient;

@BeforeAll
public void initClient() throws CerbosClientBuilder.InvalidClientConfigurationException, URISyntaxException {
String target = cerbosContainer.getTarget();
this.adminClient = new CerbosClientBuilder(target).withPlaintext().buildBlockingAdminClient("cerbos", "cerbosAdmin").withHeaders(Map.of("wibble", "wobble"));
this.adminClient = new CerbosClientBuilder(target).withPlaintext()
.buildBlockingAdminClient("cerbos", "cerbosAdmin").withHeaders(Map.of("wibble", "wobble"));
this.client = new CerbosClientBuilder(target).withPlaintext().buildBlockingClient();
loadSchemas();
loadPolicies();
this.adminClient.storeReload(true);
}

void loadSchemas() throws URISyntaxException {
Expand Down Expand Up @@ -114,7 +115,8 @@ private void addPolicies(AddOrUpdatePolicyRequestBuilder requestBuilder, File fi

requestBuilder.with(new FileReader(file));
} catch (ValidationException ve) {
ve.getViolations().stream().forEach(e -> System.out.printf("%s - %s\n", e.toProto().getField(), e.toProto().getMessage()));
ve.getViolations().stream()
.forEach(e -> System.out.printf("%s - %s\n", e.toProto().getField(), e.toProto().getMessage()));
throw new RuntimeException(ve);
} catch (Exception e) {
throw new RuntimeException(e);
Expand All @@ -130,10 +132,12 @@ void listPoliciesWithoutFilter() {

@Test
void listPoliciesWithFilter() {
List<String> have = this.adminClient.listAllPolicies(Optional.of("leave"), Optional.empty(), Optional.of("acme"));
List<String> have = this.adminClient.listAllPolicies(Optional.of("leave"), Optional.empty(),
Optional.of("acme"));
Assertions.assertNotNull(have);
Assertions.assertEquals(3, have.size());
Assertions.assertIterableEquals(List.of("resource.leave_request.vdefault/acme", "resource.leave_request.vdefault/acme.hr", "resource.leave_request.vdefault/acme.hr.uk"), have);
Assertions.assertIterableEquals(List.of("resource.leave_request.vdefault/acme",
"resource.leave_request.vdefault/acme.hr", "resource.leave_request.vdefault/acme.hr.uk"), have);
}

@Test
Expand Down Expand Up @@ -233,4 +237,4 @@ public boolean accept(File f) {
return (fileName.endsWith(".yaml") || fileName.endsWith(".yml") || fileName.endsWith(".json"));
}
}
}
}
8 changes: 8 additions & 0 deletions src/test/resources/config/admin-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ auxData:
local:
file: /config/verify_key.jwk

audit:
enabled: true
accessLogsEnabled: false
decisionLogsEnabled: true
backend: file
file:
path: stdout

engine:
defaultPolicyVersion: "default"

Expand Down
Loading