Search in sources :

Example 1 with InMemoryNamespaceClient

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

the class AuthorizationUtilTest method init.

@BeforeClass
public static void init() throws Exception {
    cConf = CConfiguration.create();
    // Note: it is important to initialize the UGI before we call AuthorizationUtil.getAppAuthorizingUser(..)
    // which uses KerberosName since KerberosName expect the rules for matching to be set. See
    // http://lucene.472066.n3.nabble.com/KerberosName-rules-are-null-during-KerberosName-getShortName-
    // in-KerberosAuthenticationHandler-td4074309.html for more context
    username = UserGroupInformation.getCurrentUser().getShortUserName();
    namespaceClient = new InMemoryNamespaceClient();
    authenticationContext = new AuthenticationTestContext();
}
Also used : AuthenticationTestContext(co.cask.cdap.security.auth.context.AuthenticationTestContext) InMemoryNamespaceClient(co.cask.cdap.common.namespace.InMemoryNamespaceClient) BeforeClass(org.junit.BeforeClass)

Example 2 with InMemoryNamespaceClient

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

the class UGIProviderTest method init.

@BeforeClass
public static void init() throws Exception {
    cConf = CConfiguration.create();
    cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
    namespaceClient = new InMemoryNamespaceClient();
    // Start KDC
    miniKdc = new MiniKdc(MiniKdc.createConf(), TEMP_FOLDER.newFolder());
    miniKdc.start();
    System.setProperty("java.security.krb5.conf", miniKdc.getKrb5conf().getAbsolutePath());
    localKeytabDirPath = TEMP_FOLDER.newFolder();
    // Generate keytab
    aliceKeytabFile = createPrincipal(localKeytabDirPath, "alice");
    bobKeytabFile = createPrincipal(localKeytabDirPath, "bob");
    eveKeytabFile = createPrincipal(localKeytabDirPath, "eve");
    // construct Kerberos PrincipalIds
    aliceKerberosPrincipalId = new KerberosPrincipalId(getPrincipal("alice"));
    bobKerberosPrincipalId = new KerberosPrincipalId(getPrincipal("bob"));
    eveKerberosPrincipalId = new KerberosPrincipalId(getPrincipal("eve"));
    // Start mini DFS cluster
    Configuration hConf = new Configuration();
    hConf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, TEMP_FOLDER.newFolder().getAbsolutePath());
    hConf.setBoolean("ipc.client.fallback-to-simple-auth-allowed", true);
    miniDFSCluster = new MiniDFSCluster.Builder(hConf).numDataNodes(1).build();
    miniDFSCluster.waitClusterUp();
    locationFactory = new FileContextLocationFactory(miniDFSCluster.getFileSystem().getConf());
    hConf = new Configuration();
    hConf.set("hadoop.security.authentication", "kerberos");
    UserGroupInformation.setConfiguration(hConf);
}
Also used : MiniDFSCluster(org.apache.hadoop.hdfs.MiniDFSCluster) CConfiguration(co.cask.cdap.common.conf.CConfiguration) Configuration(org.apache.hadoop.conf.Configuration) MiniKdc(org.apache.hadoop.minikdc.MiniKdc) InMemoryNamespaceClient(co.cask.cdap.common.namespace.InMemoryNamespaceClient) FileContextLocationFactory(org.apache.twill.filesystem.FileContextLocationFactory) KerberosPrincipalId(co.cask.cdap.proto.id.KerberosPrincipalId) BeforeClass(org.junit.BeforeClass)

Example 3 with InMemoryNamespaceClient

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

the class FileSecureStoreTest method setUp.

@Before
public void setUp() throws Exception {
    CConfiguration conf = CConfiguration.create();
    conf.set(Constants.Security.Store.FILE_PATH, STORE_PATH);
    SConfiguration sConf = SConfiguration.create();
    sConf.set(Constants.Security.Store.FILE_PASSWORD, "secret");
    InMemoryNamespaceClient namespaceClient = new InMemoryNamespaceClient();
    NamespaceMeta namespaceMeta = new NamespaceMeta.Builder().setName(NAMESPACE1).build();
    namespaceClient.create(namespaceMeta);
    namespaceMeta = new NamespaceMeta.Builder().setName(NAMESPACE2).build();
    namespaceClient.create(namespaceMeta);
    FileSecureStore fileSecureStore = new FileSecureStore(conf, sConf, namespaceClient);
    secureStoreManager = fileSecureStore;
    secureStore = fileSecureStore;
}
Also used : NamespaceMeta(co.cask.cdap.proto.NamespaceMeta) SConfiguration(co.cask.cdap.common.conf.SConfiguration) InMemoryNamespaceClient(co.cask.cdap.common.namespace.InMemoryNamespaceClient) CConfiguration(co.cask.cdap.common.conf.CConfiguration) Before(org.junit.Before)

Example 4 with InMemoryNamespaceClient

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

the class LeaderElectionMessagingServiceTest method init.

@BeforeClass
public static void init() throws IOException {
    zkServer = InMemoryZKServer.builder().setDataDir(TEMP_FOLDER.newFolder()).build();
    zkServer.startAndWait();
    cConf = CConfiguration.create();
    cConf.set(Constants.Zookeeper.QUORUM, zkServer.getConnectionStr());
    cConf.setInt(Constants.Zookeeper.CFG_SESSION_TIMEOUT_MILLIS, 2000);
    cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
    cConf.set(Constants.MessagingSystem.HTTP_SERVER_BIND_ADDRESS, InetAddress.getLocalHost().getHostName());
    cConf.set(Constants.MessagingSystem.SYSTEM_TOPICS, "topic");
    cConf.setLong(Constants.MessagingSystem.HA_FENCING_DELAY_SECONDS, 0L);
    namespaceQueryAdmin = new InMemoryNamespaceClient();
    levelDBTableFactory = new LevelDBTableFactory(cConf);
}
Also used : LevelDBTableFactory(co.cask.cdap.messaging.store.leveldb.LevelDBTableFactory) InMemoryNamespaceClient(co.cask.cdap.common.namespace.InMemoryNamespaceClient) BeforeClass(org.junit.BeforeClass)

Example 5 with InMemoryNamespaceClient

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

the class NamespaceClientRuntimeModule method getInMemoryModules.

@Override
public Module getInMemoryModules() {
    return new AbstractModule() {

        @Override
        protected void configure() {
            InMemoryNamespaceClient namespaceClient = new InMemoryNamespaceClient();
            bind(NamespaceAdmin.class).toInstance(namespaceClient);
            bind(NamespaceQueryAdmin.class).toInstance(namespaceClient);
        }
    };
}
Also used : NamespaceAdmin(co.cask.cdap.common.namespace.NamespaceAdmin) NamespaceQueryAdmin(co.cask.cdap.common.namespace.NamespaceQueryAdmin) InMemoryNamespaceClient(co.cask.cdap.common.namespace.InMemoryNamespaceClient) AbstractModule(com.google.inject.AbstractModule)

Aggregations

InMemoryNamespaceClient (co.cask.cdap.common.namespace.InMemoryNamespaceClient)6 BeforeClass (org.junit.BeforeClass)4 CConfiguration (co.cask.cdap.common.conf.CConfiguration)3 AbstractModule (com.google.inject.AbstractModule)2 Configuration (org.apache.hadoop.conf.Configuration)2 MiniDFSCluster (org.apache.hadoop.hdfs.MiniDFSCluster)2 FileContextLocationFactory (org.apache.twill.filesystem.FileContextLocationFactory)2 SConfiguration (co.cask.cdap.common.conf.SConfiguration)1 ConfigModule (co.cask.cdap.common.guice.ConfigModule)1 DiscoveryRuntimeModule (co.cask.cdap.common.guice.DiscoveryRuntimeModule)1 ZKClientModule (co.cask.cdap.common.guice.ZKClientModule)1 DefaultNamespacedLocationFactory (co.cask.cdap.common.namespace.DefaultNamespacedLocationFactory)1 NamespaceAdmin (co.cask.cdap.common.namespace.NamespaceAdmin)1 NamespaceQueryAdmin (co.cask.cdap.common.namespace.NamespaceQueryAdmin)1 NamespacedLocationFactory (co.cask.cdap.common.namespace.NamespacedLocationFactory)1 DataFabricModules (co.cask.cdap.data.runtime.DataFabricModules)1 DataSetsModules (co.cask.cdap.data.runtime.DataSetsModules)1 TransactionMetricsModule (co.cask.cdap.data.runtime.TransactionMetricsModule)1 InMemoryStreamMetaStore (co.cask.cdap.data.stream.service.InMemoryStreamMetaStore)1 StreamMetaStore (co.cask.cdap.data.stream.service.StreamMetaStore)1