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);
}
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());
}
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());
}
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());
}
Aggregations