|
@@ -49,7 +49,6 @@ import static org.apache.hadoop.yarn.service.conf.RestApiConstants.DEFAULT_UNLIM
|
|
import static org.apache.hadoop.yarn.service.exceptions.RestApiErrorMessages.*;
|
|
import static org.apache.hadoop.yarn.service.exceptions.RestApiErrorMessages.*;
|
|
import static org.junit.Assert.assertEquals;
|
|
import static org.junit.Assert.assertEquals;
|
|
import static org.junit.Assert.assertNotNull;
|
|
import static org.junit.Assert.assertNotNull;
|
|
-import static org.junit.Assert.assertTrue;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* Test for ServiceApiUtil helper methods.
|
|
* Test for ServiceApiUtil helper methods.
|
|
@@ -593,33 +592,19 @@ public class TestServiceApiUtil extends ServiceTestUtils {
|
|
SliderFileSystem sfs = ServiceTestUtils.initMockFs();
|
|
SliderFileSystem sfs = ServiceTestUtils.initMockFs();
|
|
Service app = createValidApplication("comp-a");
|
|
Service app = createValidApplication("comp-a");
|
|
KerberosPrincipal kp = new KerberosPrincipal();
|
|
KerberosPrincipal kp = new KerberosPrincipal();
|
|
- kp.setKeytab("/some/path");
|
|
|
|
|
|
+ kp.setKeytab("file:///tmp/a.keytab");
|
|
kp.setPrincipalName("user/_HOST@domain.com");
|
|
kp.setPrincipalName("user/_HOST@domain.com");
|
|
app.setKerberosPrincipal(kp);
|
|
app.setKerberosPrincipal(kp);
|
|
|
|
|
|
|
|
+ // This should succeed
|
|
try {
|
|
try {
|
|
ServiceApiUtil.validateKerberosPrincipal(app.getKerberosPrincipal());
|
|
ServiceApiUtil.validateKerberosPrincipal(app.getKerberosPrincipal());
|
|
- Assert.fail(EXCEPTION_PREFIX + "service with invalid keytab URI scheme");
|
|
|
|
- } catch (IllegalArgumentException e) {
|
|
|
|
- assertEquals(
|
|
|
|
- String.format(RestApiErrorMessages.ERROR_KEYTAB_URI_SCHEME_INVALID,
|
|
|
|
- kp.getKeytab()),
|
|
|
|
- e.getMessage());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- kp.setKeytab("/ blank / in / paths");
|
|
|
|
- try {
|
|
|
|
- ServiceApiUtil.validateKerberosPrincipal(app.getKerberosPrincipal());
|
|
|
|
- Assert.fail(EXCEPTION_PREFIX + "service with invalid keytab");
|
|
|
|
} catch (IllegalArgumentException e) {
|
|
} catch (IllegalArgumentException e) {
|
|
- // strip out the %s at the end of the RestApiErrorMessages string constant
|
|
|
|
- assertTrue(e.getMessage().contains(
|
|
|
|
- RestApiErrorMessages.ERROR_KEYTAB_URI_INVALID.substring(0,
|
|
|
|
- RestApiErrorMessages.ERROR_KEYTAB_URI_INVALID.length() - 2)));
|
|
|
|
|
|
+ Assert.fail(NO_EXCEPTION_PREFIX + e.getMessage());
|
|
}
|
|
}
|
|
|
|
|
|
- kp.setKeytab("file:///tmp/a.keytab");
|
|
|
|
- // now it should succeed
|
|
|
|
|
|
+ // Keytab with no URI scheme should succeed too
|
|
|
|
+ kp.setKeytab("/some/path");
|
|
try {
|
|
try {
|
|
ServiceApiUtil.validateKerberosPrincipal(app.getKerberosPrincipal());
|
|
ServiceApiUtil.validateKerberosPrincipal(app.getKerberosPrincipal());
|
|
} catch (IllegalArgumentException e) {
|
|
} catch (IllegalArgumentException e) {
|