Search in sources :

Example 1 with UserGroupProviderLookup

use of org.apache.nifi.authorization.UserGroupProviderLookup in project nifi by apache.

the class ManagedRangerAuthorizerTest method getStandardManagedAuthorizer.

private ManagedRangerAuthorizer getStandardManagedAuthorizer(final UserGroupProvider userGroupProvider) {
    final ManagedRangerAuthorizer managedAuthorizer = new ManagedRangerAuthorizer();
    final AuthorizerConfigurationContext configurationContext = mock(AuthorizerConfigurationContext.class);
    when(configurationContext.getProperty(eq("User Group Provider"))).thenReturn(new MockPropertyValue("user-group-provider", null));
    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"));
    when(configurationContext.getProperty(eq(RangerNiFiAuthorizer.RANGER_APP_ID_PROP))).thenReturn(new MockPropertyValue(appId));
    when(configurationContext.getProperty(eq(RangerNiFiAuthorizer.RANGER_SERVICE_TYPE_PROP))).thenReturn(new MockPropertyValue(serviceType));
    final UserGroupProviderLookup userGroupProviderLookup = mock(UserGroupProviderLookup.class);
    when(userGroupProviderLookup.getUserGroupProvider("user-group-provider")).thenReturn(userGroupProvider);
    final AuthorizerInitializationContext initializationContext = mock(AuthorizerInitializationContext.class);
    when(initializationContext.getUserGroupProviderLookup()).thenReturn(userGroupProviderLookup);
    managedAuthorizer.initialize(initializationContext);
    managedAuthorizer.onConfigured(configurationContext);
    return managedAuthorizer;
}
Also used : UserGroupProviderLookup(org.apache.nifi.authorization.UserGroupProviderLookup) MockPropertyValue(org.apache.nifi.util.MockPropertyValue) AuthorizerInitializationContext(org.apache.nifi.authorization.AuthorizerInitializationContext) AuthorizerConfigurationContext(org.apache.nifi.authorization.AuthorizerConfigurationContext)

Aggregations

AuthorizerConfigurationContext (org.apache.nifi.authorization.AuthorizerConfigurationContext)1 AuthorizerInitializationContext (org.apache.nifi.authorization.AuthorizerInitializationContext)1 UserGroupProviderLookup (org.apache.nifi.authorization.UserGroupProviderLookup)1 MockPropertyValue (org.apache.nifi.util.MockPropertyValue)1