Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: incorrect rbac resource name for subjects and connectors #405

Merged
merged 1 commit into from
Nov 21, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public ClusterLevelRoleBuilder forSchemaSubject(String subject, String patternTy

scope = new RequestScope();
scope.setClusters(clusters);
scope.addResource("Subject", "Subject:" + subject, patternType);
scope.addResource("Subject", subject, patternType);
scope.build();

return this;
Expand All @@ -59,7 +59,7 @@ public ClusterLevelRoleBuilder forAKafkaConnector(String connector) {

scope = new RequestScope();
scope.setClusters(clusters);
scope.addResource("Connector", "Connector:" + connector, patternType);
scope.addResource("Connector", connector, patternType);
scope.build();

return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void testBindSubjectRole() {
assertThat(mdsRequest.getUrl()).isEqualTo("User:foo/roles/DeveloperRead/bindings");
assertThat(mdsRequest.getJsonEntity())
.isEqualTo(
"{\"resourcePatterns\":[{\"name\":\"Subject:topic-value\",\"patternType\":\"LITERAL\",\"resourceType\":\"Subject\"}],\"scope\":{\"clusters\":{\"kafka-cluster\":\"\",\"schema-registry-cluster\":\"\"}}}");
"{\"resourcePatterns\":[{\"name\":\"topic-value\",\"patternType\":\"LITERAL\",\"resourceType\":\"Subject\"}],\"scope\":{\"clusters\":{\"kafka-cluster\":\"\",\"schema-registry-cluster\":\"\"}}}");
}

@Test
Expand All @@ -41,6 +41,25 @@ public void testBindSubjectRoleWithoutResourceType() {
assertThat(mdsRequest.getUrl()).isEqualTo("User:foo/roles/DeveloperRead/bindings");
assertThat(mdsRequest.getJsonEntity())
.isEqualTo(
"{\"resourcePatterns\":[{\"name\":\"Subject:topic-value\",\"patternType\":\"LITERAL\",\"resourceType\":\"Subject\"}],\"scope\":{\"clusters\":{\"kafka-cluster\":\"\",\"schema-registry-cluster\":\"\"}}}");
"{\"resourcePatterns\":[{\"name\":\"topic-value\",\"patternType\":\"LITERAL\",\"resourceType\":\"Subject\"}],\"scope\":{\"clusters\":{\"kafka-cluster\":\"\",\"schema-registry-cluster\":\"\"}}}");
}

@Test
public void testBindConnectRole() {
String principal = "User:foo";
String connectorName = "jdbc-sink";

TopologyAclBinding binding =
apiClient
.bind(principal, DEVELOPER_READ)
.forAKafkaConnector(connectorName)
.apply("Connector", connectorName);

MDSRequest mdsRequest = apiClient.buildRequest(binding);

assertThat(mdsRequest.getUrl()).isEqualTo("User:foo/roles/DeveloperRead/bindings");
assertThat(mdsRequest.getJsonEntity())
.isEqualTo(
"{\"resourcePatterns\":[{\"name\":\"jdbc-sink\",\"patternType\":\"LITERAL\",\"resourceType\":\"Connector\"}],\"scope\":{\"clusters\":{\"kafka-cluster\":\"\",\"connect-cluster\":\"\"}}}");
}
}