use of co.cask.cdap.proto.security.Principal in project cdap by caskdata.
the class MetadataAdminAuthorizationTest method setup.
@BeforeClass
public static void setup() throws Exception {
cConf = createCConf();
final Injector injector = AppFabricTestHelper.getInjector(cConf);
metadataAdmin = injector.getInstance(MetadataAdmin.class);
authorizer = injector.getInstance(AuthorizerInstantiator.class).get();
appFabricServer = injector.getInstance(AppFabricServer.class);
appFabricServer.startAndWait();
// Wait for the default namespace creation
String user = AuthorizationUtil.getEffectiveMasterUser(cConf);
authorizer.grant(Authorizable.fromEntityId(NamespaceId.DEFAULT), new Principal(user, Principal.PrincipalType.USER), Collections.singleton(Action.ADMIN));
// Starting the Appfabric server will create the default namespace
Tasks.waitFor(true, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return injector.getInstance(NamespaceAdmin.class).exists(NamespaceId.DEFAULT);
}
}, 5, TimeUnit.SECONDS);
authorizer.revoke(Authorizable.fromEntityId(NamespaceId.DEFAULT), new Principal(user, Principal.PrincipalType.USER), Collections.singleton(Action.ADMIN));
}
Aggregations