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

[#5180][part-1] improvement(test): Add more integration tests about access control #5316

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
3 changes: 3 additions & 0 deletions authorizations/authorization-ranger/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ tasks {
}

tasks.test {
doFirst {
environment("HADOOP_USER_NAME", "test")
}
dependsOn(":catalogs:catalog-hive:jar", ":catalogs:catalog-hive:runtimeJars")

val skipITs = project.hasProperty("skipITs")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ public List<RangerSecurableObject> translatePrivilege(SecurableObject securableO
.forEach(
gravitinoPrivilege -> {
Set<RangerPrivilege> rangerPrivileges = new HashSet<>();
// Ignore unsupported privileges
if (!privilegesMappingRule().containsKey(gravitinoPrivilege.name())) {
return;
}
privilegesMappingRule().get(gravitinoPrivilege.name()).stream()
.forEach(
rangerPrivilege ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -681,15 +681,6 @@ public boolean validAuthorizationOperation(List<SecurableObject> securableObject
securableObject.privileges().stream()
.forEach(
privilege -> {
if (!allowPrivilegesRule().contains(privilege.name())) {
LOG.error(
"Authorization to ignore privilege({}) on metadata object({})!",
privilege.name(),
securableObject.fullName());
match.set(false);
return;
}

if (!privilege.canBindTo(securableObject.type())) {
LOG.error(
"The privilege({}) is not supported for the metadata object({})!",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,11 @@ public void testValidAuthorizationOperation() {
String.format("catalog.schema"),
MetadataObject.Type.SCHEMA,
Lists.newArrayList(Privileges.ReadFileset.allow()));
Assertions.assertFalse(
Assertions.assertTrue(
rangerAuthPlugin.validAuthorizationOperation(Arrays.asList(createFilesetInMetalake)));
Assertions.assertFalse(
Assertions.assertTrue(
rangerAuthPlugin.validAuthorizationOperation(Arrays.asList(createFilesetInCatalog)));
Assertions.assertFalse(
Assertions.assertTrue(
rangerAuthPlugin.validAuthorizationOperation(Arrays.asList(createFilesetInSchema)));

// Ignore the Topic operation
Expand All @@ -327,13 +327,13 @@ public void testValidAuthorizationOperation() {
String.format("catalog.schema.fileset"),
MetadataObject.Type.FILESET,
Lists.newArrayList(Privileges.WriteFileset.allow()));
Assertions.assertFalse(
Assertions.assertTrue(
rangerAuthPlugin.validAuthorizationOperation(Arrays.asList(writeFilesetInMetalake)));
Assertions.assertFalse(
Assertions.assertTrue(
rangerAuthPlugin.validAuthorizationOperation(Arrays.asList(writeFilesetInCatalog)));
Assertions.assertFalse(
Assertions.assertTrue(
rangerAuthPlugin.validAuthorizationOperation(Arrays.asList(writeFilesetInScheam)));
Assertions.assertFalse(
Assertions.assertTrue(
rangerAuthPlugin.validAuthorizationOperation(Arrays.asList(writeFileset)));

// Ignore the Fileset operation
Expand All @@ -357,14 +357,13 @@ public void testValidAuthorizationOperation() {
String.format("catalog.schema.table"),
MetadataObject.Type.FILESET,
Lists.newArrayList(Privileges.ReadFileset.allow()));
Assertions.assertFalse(
Assertions.assertTrue(
rangerAuthPlugin.validAuthorizationOperation(Arrays.asList(readFilesetInMetalake)));
Assertions.assertFalse(
Assertions.assertTrue(
rangerAuthPlugin.validAuthorizationOperation(Arrays.asList(readFilesetInCatalog)));
Assertions.assertFalse(
Assertions.assertTrue(
rangerAuthPlugin.validAuthorizationOperation(Arrays.asList(readFilesetInSchema)));
Assertions.assertFalse(
rangerAuthPlugin.validAuthorizationOperation(Arrays.asList(readFileset)));
Assertions.assertTrue(rangerAuthPlugin.validAuthorizationOperation(Arrays.asList(readFileset)));

// Ignore the Topic operation
SecurableObject createTopicInMetalake =
Expand All @@ -382,11 +381,11 @@ public void testValidAuthorizationOperation() {
String.format("catalog.schema"),
MetadataObject.Type.SCHEMA,
Lists.newArrayList(Privileges.CreateTopic.allow()));
Assertions.assertFalse(
Assertions.assertTrue(
rangerAuthPlugin.validAuthorizationOperation(Arrays.asList(createTopicInMetalake)));
Assertions.assertFalse(
Assertions.assertTrue(
rangerAuthPlugin.validAuthorizationOperation(Arrays.asList(createTopicInCatalog)));
Assertions.assertFalse(
Assertions.assertTrue(
rangerAuthPlugin.validAuthorizationOperation(Arrays.asList(createTopicInSchema)));

SecurableObject produceTopicInMetalake =
Expand All @@ -409,13 +408,13 @@ public void testValidAuthorizationOperation() {
String.format("catalog.schema.fileset"),
MetadataObject.Type.TOPIC,
Lists.newArrayList(Privileges.ProduceTopic.allow()));
Assertions.assertFalse(
Assertions.assertTrue(
rangerAuthPlugin.validAuthorizationOperation(Arrays.asList(produceTopicInMetalake)));
Assertions.assertFalse(
Assertions.assertTrue(
rangerAuthPlugin.validAuthorizationOperation(Arrays.asList(produceTopicInCatalog)));
Assertions.assertFalse(
Assertions.assertTrue(
rangerAuthPlugin.validAuthorizationOperation(Arrays.asList(produceTopicInSchema)));
Assertions.assertFalse(
Assertions.assertTrue(
rangerAuthPlugin.validAuthorizationOperation(Arrays.asList(produceTopic)));

SecurableObject consumeTopicInMetalake =
Expand All @@ -438,13 +437,13 @@ public void testValidAuthorizationOperation() {
String.format("catalog.schema.topic"),
MetadataObject.Type.TOPIC,
Lists.newArrayList(Privileges.ConsumeTopic.allow()));
Assertions.assertFalse(
Assertions.assertTrue(
rangerAuthPlugin.validAuthorizationOperation(Arrays.asList(consumeTopicInMetalake)));
Assertions.assertFalse(
Assertions.assertTrue(
rangerAuthPlugin.validAuthorizationOperation(Arrays.asList(consumeTopicInCatalog)));
Assertions.assertFalse(
Assertions.assertTrue(
rangerAuthPlugin.validAuthorizationOperation(Arrays.asList(consumeTopicInSchema)));
Assertions.assertFalse(
Assertions.assertTrue(
rangerAuthPlugin.validAuthorizationOperation(Arrays.asList(consumeTopic)));
}

Expand Down
Loading
Loading