Search in sources :

Example 1 with NamespaceAdmin

use of co.cask.cdap.common.namespace.NamespaceAdmin in project cdap by caskdata.

the class AuthorizationBootstrapperTest method setup.

@BeforeClass
public static void setup() throws Exception {
    CConfiguration cConf = CConfiguration.create();
    cConf.set(Constants.CFG_LOCAL_DATA_DIR, TMP_FOLDER.newFolder().getAbsolutePath());
    cConf.setBoolean(Constants.Security.ENABLED, true);
    cConf.setBoolean(Constants.Security.KERBEROS_ENABLED, false);
    cConf.setBoolean(Constants.Security.Authorization.ENABLED, true);
    Location deploymentJar = AppJarHelper.createDeploymentJar(new LocalLocationFactory(TMP_FOLDER.newFolder()), InMemoryAuthorizer.class);
    cConf.set(Constants.Security.Authorization.EXTENSION_JAR_PATH, deploymentJar.toURI().getPath());
    // make Alice an admin user, so she can create namespaces
    cConf.set(Constants.Security.Authorization.ADMIN_USERS, ADMIN_USER.getName());
    instanceId = new InstanceId(cConf.get(Constants.INSTANCE_NAME));
    // setup a system artifact
    File systemArtifactsDir = TMP_FOLDER.newFolder();
    cConf.set(Constants.AppFabric.SYSTEM_ARTIFACTS_DIR, systemArtifactsDir.getAbsolutePath());
    createSystemArtifact(systemArtifactsDir);
    Injector injector = Guice.createInjector(new AppFabricTestModule(cConf));
    namespaceQueryAdmin = injector.getInstance(NamespaceQueryAdmin.class);
    namespaceAdmin = injector.getInstance(NamespaceAdmin.class);
    defaultNamespaceEnsurer = new DefaultNamespaceEnsurer(namespaceAdmin);
    discoveryServiceClient = injector.getInstance(DiscoveryServiceClient.class);
    txManager = injector.getInstance(TransactionManager.class);
    datasetService = injector.getInstance(DatasetService.class);
    systemArtifactLoader = injector.getInstance(SystemArtifactLoader.class);
    authorizationBootstrapper = injector.getInstance(AuthorizationBootstrapper.class);
    artifactRepository = injector.getInstance(ArtifactRepository.class);
    dsFramework = injector.getInstance(DatasetFramework.class);
    authorizationEnforcer = injector.getInstance(AuthorizationEnforcer.class);
}
Also used : DiscoveryServiceClient(org.apache.twill.discovery.DiscoveryServiceClient) InstanceId(co.cask.cdap.proto.id.InstanceId) NamespaceAdmin(co.cask.cdap.common.namespace.NamespaceAdmin) DatasetService(co.cask.cdap.data2.datafabric.dataset.service.DatasetService) ArtifactRepository(co.cask.cdap.internal.app.runtime.artifact.ArtifactRepository) AuthorizationEnforcer(co.cask.cdap.security.spi.authorization.AuthorizationEnforcer) DefaultNamespaceEnsurer(co.cask.cdap.internal.app.namespace.DefaultNamespaceEnsurer) CConfiguration(co.cask.cdap.common.conf.CConfiguration) DatasetFramework(co.cask.cdap.data2.dataset2.DatasetFramework) AuthorizationBootstrapper(co.cask.cdap.security.authorization.AuthorizationBootstrapper) Injector(com.google.inject.Injector) TransactionManager(org.apache.tephra.TransactionManager) SystemArtifactLoader(co.cask.cdap.internal.app.runtime.artifact.SystemArtifactLoader) NamespaceQueryAdmin(co.cask.cdap.common.namespace.NamespaceQueryAdmin) AppFabricTestModule(co.cask.cdap.internal.guice.AppFabricTestModule) LocalLocationFactory(org.apache.twill.filesystem.LocalLocationFactory) File(java.io.File) Location(org.apache.twill.filesystem.Location) BeforeClass(org.junit.BeforeClass)

Example 2 with NamespaceAdmin

use of co.cask.cdap.common.namespace.NamespaceAdmin in project cdap by caskdata.

the class OpenCloseDataSetTest method setup.

@BeforeClass
public static void setup() throws Exception {
    NamespacedLocationFactory namespacedLocationFactory = AppFabricTestHelper.getInjector().getInstance(NamespacedLocationFactory.class);
    namespaceHomeLocation = namespacedLocationFactory.get(DefaultId.NAMESPACE);
    NamespaceAdmin namespaceAdmin = AppFabricTestHelper.getInjector().getInstance(NamespaceAdmin.class);
    namespaceAdmin.create(new NamespaceMeta.Builder().setName(DefaultId.NAMESPACE).build());
    Locations.mkdirsIfNotExists(namespaceHomeLocation);
}
Also used : NamespaceMeta(co.cask.cdap.proto.NamespaceMeta) NamespaceAdmin(co.cask.cdap.common.namespace.NamespaceAdmin) NamespacedLocationFactory(co.cask.cdap.common.namespace.NamespacedLocationFactory) BeforeClass(org.junit.BeforeClass)

Example 3 with NamespaceAdmin

use of co.cask.cdap.common.namespace.NamespaceAdmin in project cdap by caskdata.

the class FlowTest method init.

@BeforeClass
public static void init() throws Exception {
    NamespaceAdmin namespaceAdmin = AppFabricTestHelper.getInjector().getInstance(NamespaceAdmin.class);
    namespaceAdmin.create(NamespaceMeta.DEFAULT);
    metricStore = AppFabricTestHelper.getInjector().getInstance(MetricStore.class);
}
Also used : MetricStore(co.cask.cdap.api.metrics.MetricStore) NamespaceAdmin(co.cask.cdap.common.namespace.NamespaceAdmin) BeforeClass(org.junit.BeforeClass)

Example 4 with NamespaceAdmin

use of co.cask.cdap.common.namespace.NamespaceAdmin in project cdap by caskdata.

the class SystemMetadataAuditPublishTest method setup.

@BeforeClass
public static void setup() {
    cConf = CConfiguration.create();
    cConf.setBoolean(Constants.Audit.ENABLED, true);
    Injector injector = AppFabricTestHelper.getInjector(cConf, new AbstractModule() {

        @Override
        protected void configure() {
            bind(MetadataStore.class).to(DefaultMetadataStore.class);
            install(new AuditModule().getInMemoryModules());
        }
    });
    auditPublisher = injector.getInstance(InMemoryAuditPublisher.class);
    namespaceAdmin = injector.getInstance(NamespaceAdmin.class);
    scheduler = injector.getInstance(Scheduler.class);
    if (scheduler instanceof Service) {
        ((Service) scheduler).startAndWait();
    }
}
Also used : InMemoryAuditPublisher(co.cask.cdap.data2.audit.InMemoryAuditPublisher) Injector(com.google.inject.Injector) Scheduler(co.cask.cdap.scheduler.Scheduler) NamespaceAdmin(co.cask.cdap.common.namespace.NamespaceAdmin) Service(com.google.common.util.concurrent.Service) AuditModule(co.cask.cdap.data2.audit.AuditModule) DefaultMetadataStore(co.cask.cdap.data2.metadata.store.DefaultMetadataStore) AbstractModule(com.google.inject.AbstractModule) BeforeClass(org.junit.BeforeClass)

Example 5 with NamespaceAdmin

use of co.cask.cdap.common.namespace.NamespaceAdmin in project cdap by caskdata.

the class LocalStreamFileJanitorTest method init.

@BeforeClass
public static void init() throws IOException {
    cConf.set(Constants.CFG_LOCAL_DATA_DIR, tmpFolder.newFolder().getAbsolutePath());
    Injector injector = Guice.createInjector(new ConfigModule(cConf), new NonCustomLocationUnitTestModule().getModule(), new SystemDatasetRuntimeModule().getInMemoryModules(), Modules.override(new DataSetsModules().getInMemoryModules()).with(new AbstractModule() {

        @Override
        protected void configure() {
            // bind to an in mem implementation for this test since the DefaultOwnerStore uses transaction and in this
            // test we are not starting a transaction service
            bind(OwnerStore.class).to(InMemoryOwnerStore.class).in(Scopes.SINGLETON);
        }
    }), new TransactionMetricsModule(), new DataFabricLevelDBModule(), new DiscoveryRuntimeModule().getInMemoryModules(), new NamespaceClientRuntimeModule().getInMemoryModules(), new ExploreClientModule(), new ViewAdminModules().getInMemoryModules(), new AuthorizationTestModule(), new AuthorizationEnforcementModule().getInMemoryModules(), new AuthenticationContextModules().getNoOpModule(), Modules.override(new StreamAdminModules().getStandaloneModules()).with(new AbstractModule() {

        @Override
        protected void configure() {
            bind(StreamMetaStore.class).to(InMemoryStreamMetaStore.class);
            bind(UGIProvider.class).to(UnsupportedUGIProvider.class);
        }
    }), new AbstractModule() {

        @Override
        protected void configure() {
            // We don't need notification in this test, hence inject an no-op one
            bind(NotificationFeedManager.class).to(NoOpNotificationFeedManager.class);
            bind(NamespaceStore.class).to(InMemoryNamespaceStore.class);
            bind(OwnerAdmin.class).to(DefaultOwnerAdmin.class);
        }
    });
    locationFactory = injector.getInstance(LocationFactory.class);
    namespaceAdmin = injector.getInstance(NamespaceAdmin.class);
    namespacedLocationFactory = injector.getInstance(NamespacedLocationFactory.class);
    namespaceStore = injector.getInstance(NamespaceStore.class);
    streamAdmin = injector.getInstance(StreamAdmin.class);
    fileWriterFactory = injector.getInstance(StreamFileWriterFactory.class);
    streamCoordinatorClient = injector.getInstance(StreamCoordinatorClient.class);
    streamCoordinatorClient.startAndWait();
}
Also used : NamespaceClientRuntimeModule(co.cask.cdap.common.namespace.guice.NamespaceClientRuntimeModule) ConfigModule(co.cask.cdap.common.guice.ConfigModule) UGIProvider(co.cask.cdap.security.impersonation.UGIProvider) UnsupportedUGIProvider(co.cask.cdap.security.impersonation.UnsupportedUGIProvider) NamespacedLocationFactory(co.cask.cdap.common.namespace.NamespacedLocationFactory) TransactionMetricsModule(co.cask.cdap.data.runtime.TransactionMetricsModule) DataFabricLevelDBModule(co.cask.cdap.data.runtime.DataFabricLevelDBModule) ViewAdminModules(co.cask.cdap.data.view.ViewAdminModules) Injector(com.google.inject.Injector) InMemoryStreamMetaStore(co.cask.cdap.data.stream.service.InMemoryStreamMetaStore) StreamMetaStore(co.cask.cdap.data.stream.service.StreamMetaStore) SystemDatasetRuntimeModule(co.cask.cdap.data.runtime.SystemDatasetRuntimeModule) DiscoveryRuntimeModule(co.cask.cdap.common.guice.DiscoveryRuntimeModule) AuthenticationContextModules(co.cask.cdap.security.auth.context.AuthenticationContextModules) DataSetsModules(co.cask.cdap.data.runtime.DataSetsModules) NamespaceStore(co.cask.cdap.store.NamespaceStore) InMemoryNamespaceStore(co.cask.cdap.store.InMemoryNamespaceStore) NamespaceAdmin(co.cask.cdap.common.namespace.NamespaceAdmin) NonCustomLocationUnitTestModule(co.cask.cdap.common.guice.NonCustomLocationUnitTestModule) DefaultOwnerAdmin(co.cask.cdap.security.impersonation.DefaultOwnerAdmin) AuthorizationTestModule(co.cask.cdap.security.authorization.AuthorizationTestModule) InMemoryOwnerStore(co.cask.cdap.security.impersonation.InMemoryOwnerStore) AbstractModule(com.google.inject.AbstractModule) NamespacedLocationFactory(co.cask.cdap.common.namespace.NamespacedLocationFactory) LocationFactory(org.apache.twill.filesystem.LocationFactory) StreamAdmin(co.cask.cdap.data2.transaction.stream.StreamAdmin) ExploreClientModule(co.cask.cdap.explore.guice.ExploreClientModule) NoOpNotificationFeedManager(co.cask.cdap.notifications.feeds.service.NoOpNotificationFeedManager) InMemoryNamespaceStore(co.cask.cdap.store.InMemoryNamespaceStore) AuthorizationEnforcementModule(co.cask.cdap.security.authorization.AuthorizationEnforcementModule) BeforeClass(org.junit.BeforeClass)

Aggregations

NamespaceAdmin (co.cask.cdap.common.namespace.NamespaceAdmin)20 BeforeClass (org.junit.BeforeClass)13 CConfiguration (co.cask.cdap.common.conf.CConfiguration)10 Injector (com.google.inject.Injector)10 AbstractModule (com.google.inject.AbstractModule)9 TransactionManager (org.apache.tephra.TransactionManager)9 NamespacedLocationFactory (co.cask.cdap.common.namespace.NamespacedLocationFactory)8 DatasetService (co.cask.cdap.data2.datafabric.dataset.service.DatasetService)8 ConfigModule (co.cask.cdap.common.guice.ConfigModule)7 DiscoveryRuntimeModule (co.cask.cdap.common.guice.DiscoveryRuntimeModule)6 DatasetOpExecutor (co.cask.cdap.data2.datafabric.dataset.service.executor.DatasetOpExecutor)6 NamespaceMeta (co.cask.cdap.proto.NamespaceMeta)6 AuthorizationEnforcementModule (co.cask.cdap.security.authorization.AuthorizationEnforcementModule)6 DefaultOwnerAdmin (co.cask.cdap.security.impersonation.DefaultOwnerAdmin)6 NonCustomLocationUnitTestModule (co.cask.cdap.common.guice.NonCustomLocationUnitTestModule)5 NamespaceClientRuntimeModule (co.cask.cdap.common.namespace.guice.NamespaceClientRuntimeModule)5 ExploreClientModule (co.cask.cdap.explore.guice.ExploreClientModule)5 File (java.io.File)5 IOModule (co.cask.cdap.common.guice.IOModule)4 DatasetFramework (co.cask.cdap.data2.dataset2.DatasetFramework)4