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

ISSUE-685: Updates related to removing of none-sb and none-sv resources #684

Merged
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 @@ -32,9 +32,7 @@ public class RangerSchemaRegistryAuthorizerImpl implements Authorizer {
private static final String RANGER_RESOURCE_SCHEMA_GROUP = "schema-group";
private static final String RANGER_RESOURCE_SCHEMA_METADATA = "schema-metadata";
private static final String RANGER_RESOURCE_SCHEMA_BRANCH = "schema-branch";
private static final String RANGER_RESOURCE_NONE_SCHEMA_BRANCH = "none-sb";
private static final String RANGER_RESOURCE_SCHEMA_VERSION = "schema-version";
private static final String RANGER_RESOURCE_NONE_SCHEMA_VERSION = "none-sv";

private final RangerBasePlugin plg;

Expand Down Expand Up @@ -89,12 +87,7 @@ RangerAccessResourceImpl registryResource2RangerResource(Resource registryResour
rangerResource.setValue(RANGER_RESOURCE_SCHEMA_VERSION, "ANY_VALUE");
return rangerResource;
}
case SCHEMA_BRANCH: {
rangerResource.setValue(RANGER_RESOURCE_NONE_SCHEMA_VERSION, "ANY_VALUE");
return rangerResource;
}
case SCHEMA_METADATA: {
rangerResource.setValue(RANGER_RESOURCE_NONE_SCHEMA_BRANCH, "ANY_VALUE");
case SCHEMA_METADATA: case SCHEMA_BRANCH: {
return rangerResource;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;

import com.hortonworks.registries.schemaregistry.authorizer.core.Authorizer;
import com.hortonworks.registries.schemaregistry.authorizer.core.Authorizer.UserAndGroups;
Expand Down Expand Up @@ -715,24 +714,22 @@ public void registryResource2RangerResource() {
Authorizer.Resource schema =
new Authorizer.SchemaMetadataResource("Group", "Schema");
rangerAccessResource = rangerSchemaRegistryAuthorizer.registryResource2RangerResource(schema);
assertThat(rangerAccessResource.getKeys().size(), is(3));
assertThat(rangerAccessResource.getKeys().size(), is(2));
assertTrue(rangerAccessResource.exists("schema-group"));
assertThat(rangerAccessResource.getValue("schema-group"), is("Group"));
assertTrue(rangerAccessResource.exists("schema-metadata"));
assertThat(rangerAccessResource.getValue("schema-metadata"), is("Schema"));
assertTrue(rangerAccessResource.exists("none-sb"));

Authorizer.Resource branch =
new Authorizer.SchemaBranchResource("Group", "Schema", "Branch");
rangerAccessResource = rangerSchemaRegistryAuthorizer.registryResource2RangerResource(branch);
assertThat(rangerAccessResource.getKeys().size(), is(4));
assertThat(rangerAccessResource.getKeys().size(), is(3));
assertTrue(rangerAccessResource.exists("schema-group"));
assertThat(rangerAccessResource.getValue("schema-group"), is("Group"));
assertTrue(rangerAccessResource.exists("schema-metadata"));
assertThat(rangerAccessResource.getValue("schema-metadata"), is("Schema"));
assertTrue(rangerAccessResource.exists("schema-branch"));
assertThat(rangerAccessResource.getValue("schema-branch"), is("Branch"));
assertTrue(rangerAccessResource.exists("none-sv"));

Authorizer.Resource version =
new Authorizer.SchemaVersionResource("Group", "Schema", "Branch");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,12 @@
},
{
"service": "SR1",
"name": "P3 - schema-group, schema-metadata, none-sb",
"name": "P3 - schema-group, schema-metadata",
"policyType": 0,
"policyPriority": 0,
"description": "Policy for all - schema-group, schema-metadata, none-sb",
"description": "Policy for all - schema-group, schema-metadata",
"isAuditEnabled": true,
"resources": {
"none-sb": {
"values": [
"*"
],
"isExcludes": false,
"isRecursive": false
},
"schema-metadata": {
"values": [
"Schema1", "Schema3", "__Sch*", "Schema5"
Expand Down Expand Up @@ -337,10 +330,10 @@
},
{
"service": "SR1",
"name": "P4 - schema-group, schema-metadata, schema-branch, none-sv",
"name": "P4 - schema-group, schema-metadata, schema-branch",
"policyType": 0,
"policyPriority": 0,
"description": "Policy for all - schema-group, schema-metadata, schema-branch, none-sv",
"description": "Policy for all - schema-group, schema-metadata, schema-branch",
"isAuditEnabled": true,
"resources": {
"schema-branch": {
Expand All @@ -363,13 +356,6 @@
],
"isExcludes": false,
"isRecursive": false
},
"none-sv": {
"values": [
"*"
],
"isExcludes": false,
"isRecursive": false
}
},
"policyItems":[
Expand Down Expand Up @@ -1119,31 +1105,6 @@
],
"isValidLeaf": false
},
{
"itemId": 31,
"name": "none-sb",
"type": "string",
"level": 30,
"parent": "schema-metadata",
"mandatory": true,
"lookupSupported": true,
"recursiveSupported": false,
"excludesSupported": false,
"matcher": "org.apache.ranger.plugin.resourcematcher.RangerDefaultResourceMatcher",
"matcherOptions": {
"wildCard": "true",
"ignoreCase": "true"
},
"validationRegEx": "^\\*$",
"validationMessage": "",
"uiHint": "",
"label": "None",
"description": "None",
"accessTypeRestrictions": [

],
"isValidLeaf": true
},
{
"itemId": 32,
"name": "schema-branch",
Expand All @@ -1169,31 +1130,6 @@
],
"isValidLeaf": false
},
{
"itemId": 41,
"name": "none-sv",
"type": "string",
"level": 40,
"parent": "schema-branch",
"mandatory": true,
"lookupSupported": true,
"recursiveSupported": false,
"excludesSupported": false,
"matcher": "org.apache.ranger.plugin.resourcematcher.RangerDefaultResourceMatcher",
"matcherOptions": {
"wildCard": "true",
"ignoreCase": "true"
},
"validationRegEx": "^\\*$",
"validationMessage": "",
"uiHint": "",
"label": "None",
"description": "None",
"accessTypeRestrictions": [

],
"isValidLeaf": true
},
{
"itemId": 42,
"name": "schema-version",
Expand Down