use of org.apache.oozie.cli.OozieCLI in project oozie by apache.
the class TestOozieCLI method testSubmitDoAs.
public void testSubmitDoAs() throws Exception {
setSystemProperty("oozie.authentication.simple.anonymous.allowed", "false");
runTest(END_POINTS, SERVLET_CLASSES, IS_SECURITY_ENABLED, new Callable<Void>() {
@Override
public Void call() throws Exception {
String oozieUrl = getContextURL();
Path appPath = new Path(getFsTestCaseDir(), "app");
getFileSystem().mkdirs(appPath);
getFileSystem().create(new Path(appPath, "workflow.xml")).close();
String[] args = new String[] { "job", "-submit", "-oozie", oozieUrl, "-config", createConfigFile(appPath.toString()), "-doas", getTestUser2() };
assertEquals(0, new OozieCLI().run(args));
assertEquals("submit", MockDagEngineService.did);
assertEquals(getTestUser2(), MockDagEngineService.user);
return null;
}
});
}
use of org.apache.oozie.cli.OozieCLI in project oozie by apache.
the class TestAuthFilterAuthOozieClient method testClientWithoutAnonymous.
public void testClientWithoutAnonymous() throws Exception {
Configuration conf = new Configuration(false);
conf.set("oozie.authentication.simple.anonymous.allowed", "false");
runTest(new Callable<Void>() {
public Void call() throws Exception {
String oozieUrl = getContextURL();
String[] args = new String[] { "admin", "-status", "-oozie", oozieUrl };
assertEquals(0, new OozieCLI().run(args));
return null;
}
}, conf);
}
use of org.apache.oozie.cli.OozieCLI in project oozie by apache.
the class TestAuthFilterAuthOozieClient method testClientAuthTokenCache.
public void testClientAuthTokenCache() throws Exception {
Configuration conf = new Configuration(false);
// However, Hadoop 2.7.0 (HADOOP-10670) also added a FileSignerSecretProvider, which we'll use if it exists
try {
if (Class.forName("org.apache.hadoop.security.authentication.util.FileSignerSecretProvider") != null) {
String secretFile = getTestCaseConfDir() + "/auth-secret";
conf.set("oozie.authentication.signature.secret.file", secretFile);
FileWriter fw = null;
try {
fw = new FileWriter(secretFile);
fw.write(SECRET);
} finally {
if (fw != null) {
fw.close();
}
}
}
} catch (ClassNotFoundException cnfe) {
// ignore
}
conf.set("oozie.authentication.signature.secret", SECRET);
conf.set("oozie.authentication.simple.anonymous.allowed", "false");
// not using cache
AuthOozieClient.AUTH_TOKEN_CACHE_FILE.delete();
assertFalse(AuthOozieClient.AUTH_TOKEN_CACHE_FILE.exists());
runTest(new Callable<Void>() {
public Void call() throws Exception {
String oozieUrl = getContextURL();
String[] args = new String[] { "admin", "-status", "-oozie", oozieUrl };
assertEquals(0, new OozieCLI().run(args));
return null;
}
}, conf);
assertFalse(AuthOozieClient.AUTH_TOKEN_CACHE_FILE.exists());
// using cache
setSystemProperty("oozie.auth.token.cache", "true");
AuthOozieClient.AUTH_TOKEN_CACHE_FILE.delete();
assertFalse(AuthOozieClient.AUTH_TOKEN_CACHE_FILE.exists());
runTest(new Callable<Void>() {
public Void call() throws Exception {
String oozieUrl = getContextURL();
String[] args = new String[] { "admin", "-status", "-oozie", oozieUrl };
assertEquals(0, new OozieCLI().run(args));
return null;
}
}, conf);
assertTrue(AuthOozieClient.AUTH_TOKEN_CACHE_FILE.exists());
String currentCache = IOUtils.getReaderAsString(new FileReader(AuthOozieClient.AUTH_TOKEN_CACHE_FILE), -1);
// re-using cache
setSystemProperty("oozie.auth.token.cache", "true");
runTest(new Callable<Void>() {
public Void call() throws Exception {
String oozieUrl = getContextURL();
String[] args = new String[] { "admin", "-status", "-oozie", oozieUrl };
assertEquals(0, new OozieCLI().run(args));
return null;
}
}, conf);
assertTrue(AuthOozieClient.AUTH_TOKEN_CACHE_FILE.exists());
String newCache = IOUtils.getReaderAsString(new FileReader(AuthOozieClient.AUTH_TOKEN_CACHE_FILE), -1);
assertEquals(currentCache, newCache);
// re-using cache with token that will expire within 5 minutes
currentCache = writeTokenCache(System.currentTimeMillis() + 300000);
setSystemProperty("oozie.auth.token.cache", "true");
runTest(new Callable<Void>() {
public Void call() throws Exception {
String oozieUrl = getContextURL();
String[] args = new String[] { "admin", "-status", "-oozie", oozieUrl };
assertEquals(0, new OozieCLI().run(args));
return null;
}
}, conf);
assertTrue(AuthOozieClient.AUTH_TOKEN_CACHE_FILE.exists());
newCache = IOUtils.getReaderAsString(new FileReader(AuthOozieClient.AUTH_TOKEN_CACHE_FILE), -1);
assertFalse("Almost expired token should have been updated but was not", currentCache.equals(newCache));
// re-using cache with expired token
currentCache = writeTokenCache(System.currentTimeMillis() - 1000);
setSystemProperty("oozie.auth.token.cache", "true");
runTest(new Callable<Void>() {
public Void call() throws Exception {
String oozieUrl = getContextURL();
String[] args = new String[] { "admin", "-status", "-oozie", oozieUrl };
assertEquals(0, new OozieCLI().run(args));
return null;
}
}, conf);
assertTrue(AuthOozieClient.AUTH_TOKEN_CACHE_FILE.exists());
newCache = IOUtils.getReaderAsString(new FileReader(AuthOozieClient.AUTH_TOKEN_CACHE_FILE), -1);
assertFalse("Expired token should have been updated but was not", currentCache.equals(newCache));
}
use of org.apache.oozie.cli.OozieCLI in project oozie by apache.
the class TestAuthFilterAuthOozieClient method testClientWithCustomAuthenticator.
public void testClientWithCustomAuthenticator() throws Exception {
setSystemProperty("authenticator.class", Authenticator4Test.class.getName());
Configuration conf = new Configuration(false);
conf.set("oozie.authentication.simple.anonymous.allowed", "false");
Authenticator4Test.USED = false;
runTest(new Callable<Void>() {
public Void call() throws Exception {
String oozieUrl = getContextURL();
String[] args = new String[] { "admin", "-status", "-oozie", oozieUrl };
assertEquals(0, new OozieCLI().run(args));
return null;
}
}, conf);
assertTrue(Authenticator4Test.USED);
}
Aggregations