use of org.apache.nifi.util.MockPropertyValue in project nifi by apache.
the class TestRangerNiFiAuthorizer method testIntegration.
@Test
@Ignore
public void testIntegration() {
final AuthorizerInitializationContext initializationContext = Mockito.mock(AuthorizerInitializationContext.class);
final AuthorizerConfigurationContext configurationContext = Mockito.mock(AuthorizerConfigurationContext.class);
when(configurationContext.getProperty(eq(RangerNiFiAuthorizer.RANGER_SECURITY_PATH_PROP))).thenReturn(new MockPropertyValue("src/test/resources/ranger/ranger-nifi-security.xml"));
when(configurationContext.getProperty(eq(RangerNiFiAuthorizer.RANGER_AUDIT_PATH_PROP))).thenReturn(new MockPropertyValue("src/test/resources/ranger/ranger-nifi-audit.xml"));
Authorizer authorizer = new RangerNiFiAuthorizer();
try {
authorizer.initialize(initializationContext);
authorizer.onConfigured(configurationContext);
final AuthorizationRequest request = new AuthorizationRequest.Builder().resource(new Resource() {
@Override
public String getIdentifier() {
return "/system";
}
@Override
public String getName() {
return "/system";
}
@Override
public String getSafeDescription() {
return "system";
}
}).action(RequestAction.WRITE).identity("admin").resourceContext(new HashMap<>()).accessAttempt(true).anonymous(false).build();
final AuthorizationResult result = authorizer.authorize(request);
Assert.assertEquals(AuthorizationResult.denied().getResult(), result.getResult());
} finally {
authorizer.preDestruction();
}
}
use of org.apache.nifi.util.MockPropertyValue in project nifi by apache.
the class TestSchemaNamePropertyStrategy method testNameAndVersion.
@Test
public void testNameAndVersion() throws SchemaNotFoundException, IOException {
final PropertyValue nameValue = new MockPropertyValue("person");
final PropertyValue branchValue = new MockPropertyValue(null);
final PropertyValue versionValue = new MockPropertyValue("1");
final SchemaNamePropertyStrategy schemaNamePropertyStrategy = new SchemaNamePropertyStrategy(schemaRegistry, nameValue, branchValue, versionValue);
final SchemaIdentifier expectedSchemaIdentifier = SchemaIdentifier.builder().name(nameValue.getValue()).version(versionValue.asInteger()).build();
when(schemaRegistry.retrieveSchema(argThat(new SchemaIdentifierMatcher(expectedSchemaIdentifier)))).thenReturn(recordSchema);
final RecordSchema retrievedSchema = schemaNamePropertyStrategy.getSchema(Collections.emptyMap(), null, recordSchema);
assertNotNull(retrievedSchema);
}
use of org.apache.nifi.util.MockPropertyValue in project nifi by apache.
the class TestSchemaNamePropertyStrategy method testNameAndBranch.
@Test
public void testNameAndBranch() throws SchemaNotFoundException, IOException {
final PropertyValue nameValue = new MockPropertyValue("person");
final PropertyValue branchValue = new MockPropertyValue("test");
final PropertyValue versionValue = new MockPropertyValue(null);
final SchemaNamePropertyStrategy schemaNamePropertyStrategy = new SchemaNamePropertyStrategy(schemaRegistry, nameValue, branchValue, versionValue);
final SchemaIdentifier expectedSchemaIdentifier = SchemaIdentifier.builder().name(nameValue.getValue()).branch(branchValue.getValue()).build();
when(schemaRegistry.retrieveSchema(argThat(new SchemaIdentifierMatcher(expectedSchemaIdentifier)))).thenReturn(recordSchema);
final RecordSchema retrievedSchema = schemaNamePropertyStrategy.getSchema(Collections.emptyMap(), null, recordSchema);
assertNotNull(retrievedSchema);
}
use of org.apache.nifi.util.MockPropertyValue in project nifi by apache.
the class TestSchemaNamePropertyStrategy method testNameOnly.
@Test
public void testNameOnly() throws SchemaNotFoundException, IOException {
final PropertyValue nameValue = new MockPropertyValue("person");
final PropertyValue branchValue = new MockPropertyValue(null);
final PropertyValue versionValue = new MockPropertyValue(null);
final SchemaNamePropertyStrategy schemaNamePropertyStrategy = new SchemaNamePropertyStrategy(schemaRegistry, nameValue, branchValue, versionValue);
final SchemaIdentifier expectedSchemaIdentifier = SchemaIdentifier.builder().name(nameValue.getValue()).build();
when(schemaRegistry.retrieveSchema(argThat(new SchemaIdentifierMatcher(expectedSchemaIdentifier)))).thenReturn(recordSchema);
final RecordSchema retrievedSchema = schemaNamePropertyStrategy.getSchema(Collections.emptyMap(), null, recordSchema);
assertNotNull(retrievedSchema);
}
use of org.apache.nifi.util.MockPropertyValue in project nifi by apache.
the class TestSchemaNamePropertyStrategy method testNameAndBlankBranch.
@Test
public void testNameAndBlankBranch() throws SchemaNotFoundException, IOException {
final PropertyValue nameValue = new MockPropertyValue("person");
final PropertyValue branchValue = new MockPropertyValue(" ");
final PropertyValue versionValue = new MockPropertyValue(null);
final SchemaNamePropertyStrategy schemaNamePropertyStrategy = new SchemaNamePropertyStrategy(schemaRegistry, nameValue, branchValue, versionValue);
final SchemaIdentifier expectedSchemaIdentifier = SchemaIdentifier.builder().name(nameValue.getValue()).build();
when(schemaRegistry.retrieveSchema(argThat(new SchemaIdentifierMatcher(expectedSchemaIdentifier)))).thenReturn(recordSchema);
final RecordSchema retrievedSchema = schemaNamePropertyStrategy.getSchema(Collections.emptyMap(), null, recordSchema);
assertNotNull(retrievedSchema);
}
Aggregations