Search in sources :

Example 1 with UserClient

use of org.apache.nifi.registry.client.UserClient in project nifi by apache.

the class CurrentUser method doExecute.

@Override
public CurrentUserResult doExecute(final NiFiRegistryClient client, final Properties properties) throws IOException, NiFiRegistryException {
    final UserClient userClient = client.getUserClient();
    final org.apache.nifi.registry.authorization.CurrentUser currentUser = userClient.getAccessStatus();
    return new CurrentUserResult(getResultType(properties), currentUser);
}
Also used : CurrentUserResult(org.apache.nifi.toolkit.cli.impl.result.CurrentUserResult) UserClient(org.apache.nifi.registry.client.UserClient)

Example 2 with UserClient

use of org.apache.nifi.registry.client.UserClient in project nifi-registry by apache.

the class SecureNiFiRegistryClientIT method testGetAccessStatus.

@Test
public void testGetAccessStatus() throws IOException, NiFiRegistryException {
    final UserClient userClient = client.getUserClient();
    final CurrentUser currentUser = userClient.getAccessStatus();
    Assert.assertEquals("CN=user1, OU=nifi", currentUser.getIdentity());
    Assert.assertFalse(currentUser.isAnonymous());
    Assert.assertNotNull(currentUser.getResourcePermissions());
    Permissions fullAccess = new Permissions().withCanRead(true).withCanWrite(true).withCanDelete(true);
    Assert.assertEquals(fullAccess, currentUser.getResourcePermissions().getAnyTopLevelResource());
    Assert.assertEquals(fullAccess, currentUser.getResourcePermissions().getBuckets());
    Assert.assertEquals(fullAccess, currentUser.getResourcePermissions().getTenants());
    Assert.assertEquals(fullAccess, currentUser.getResourcePermissions().getPolicies());
    Assert.assertEquals(new Permissions().withCanWrite(true), currentUser.getResourcePermissions().getProxy());
}
Also used : UserClient(org.apache.nifi.registry.client.UserClient) CurrentUser(org.apache.nifi.registry.authorization.CurrentUser) Permissions(org.apache.nifi.registry.authorization.Permissions) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with UserClient

use of org.apache.nifi.registry.client.UserClient in project nifi-registry by apache.

the class SecureNiFiRegistryClientIT method testGetAccessStatusWithProxiedEntity.

@Test
public void testGetAccessStatusWithProxiedEntity() throws IOException, NiFiRegistryException {
    final String proxiedEntity = "user2";
    final UserClient userClient = client.getUserClient(proxiedEntity);
    final CurrentUser status = userClient.getAccessStatus();
    Assert.assertEquals("user2", status.getIdentity());
    Assert.assertFalse(status.isAnonymous());
}
Also used : UserClient(org.apache.nifi.registry.client.UserClient) CurrentUser(org.apache.nifi.registry.authorization.CurrentUser) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with UserClient

use of org.apache.nifi.registry.client.UserClient in project nifi-registry by apache.

the class UnsecuredNiFiRegistryClientIT method testGetAccessStatus.

@Test
public void testGetAccessStatus() throws IOException, NiFiRegistryException {
    final UserClient userClient = client.getUserClient();
    final CurrentUser currentUser = userClient.getAccessStatus();
    Assert.assertEquals("anonymous", currentUser.getIdentity());
    Assert.assertTrue(currentUser.isAnonymous());
    Assert.assertNotNull(currentUser.getResourcePermissions());
    Permissions fullAccess = new Permissions().withCanRead(true).withCanWrite(true).withCanDelete(true);
    Assert.assertEquals(fullAccess, currentUser.getResourcePermissions().getAnyTopLevelResource());
    Assert.assertEquals(fullAccess, currentUser.getResourcePermissions().getBuckets());
    Assert.assertEquals(fullAccess, currentUser.getResourcePermissions().getTenants());
    Assert.assertEquals(fullAccess, currentUser.getResourcePermissions().getPolicies());
    Assert.assertEquals(fullAccess, currentUser.getResourcePermissions().getProxy());
}
Also used : UserClient(org.apache.nifi.registry.client.UserClient) CurrentUser(org.apache.nifi.registry.authorization.CurrentUser) Permissions(org.apache.nifi.registry.authorization.Permissions) Test(org.junit.Test)

Aggregations

UserClient (org.apache.nifi.registry.client.UserClient)4 CurrentUser (org.apache.nifi.registry.authorization.CurrentUser)3 Test (org.junit.Test)3 Permissions (org.apache.nifi.registry.authorization.Permissions)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 CurrentUserResult (org.apache.nifi.toolkit.cli.impl.result.CurrentUserResult)1