|
@@ -97,6 +97,7 @@ import org.apache.hadoop.security.Credentials;
|
|
|
import org.apache.hadoop.security.UserGroupInformation;
|
|
|
import org.apache.hadoop.security.authorize.AuthorizationException;
|
|
|
import org.apache.hadoop.security.token.Token;
|
|
|
+import org.apache.hadoop.security.token.DelegationTokenIssuer;
|
|
|
import org.apache.hadoop.util.DataChecksum;
|
|
|
import org.apache.hadoop.util.ToolRunner;
|
|
|
import org.apache.hadoop.crypto.key.KeyProviderDelegationTokenExtension.DelegationTokenExtension;
|
|
@@ -118,7 +119,6 @@ import static org.mockito.Matchers.anyLong;
|
|
|
import static org.mockito.Matchers.anyObject;
|
|
|
import static org.mockito.Matchers.anyShort;
|
|
|
import static org.mockito.Mockito.withSettings;
|
|
|
-import static org.mockito.Mockito.any;
|
|
|
import static org.mockito.Mockito.anyString;
|
|
|
import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_TRASH_INTERVAL_DEFAULT;
|
|
|
import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_TRASH_INTERVAL_KEY;
|
|
@@ -1339,11 +1339,13 @@ public class TestEncryptionZones {
|
|
|
byte[] testIdentifier = "Test identifier for delegation token".getBytes();
|
|
|
|
|
|
@SuppressWarnings("rawtypes")
|
|
|
- Token<?> testToken = new Token(testIdentifier, new byte[0],
|
|
|
+ Token testToken = new Token(testIdentifier, new byte[0],
|
|
|
new Text(), new Text());
|
|
|
- Mockito.when(((DelegationTokenExtension)keyProvider).
|
|
|
- addDelegationTokens(anyString(), (Credentials)any())).
|
|
|
- thenReturn(new Token<?>[] { testToken });
|
|
|
+ Mockito.when(((DelegationTokenIssuer)keyProvider).
|
|
|
+ getCanonicalServiceName()).thenReturn("service");
|
|
|
+ Mockito.when(((DelegationTokenIssuer)keyProvider).
|
|
|
+ getDelegationToken(anyString())).
|
|
|
+ thenReturn(testToken);
|
|
|
|
|
|
dfs.getClient().setKeyProvider(keyProvider);
|
|
|
|
|
@@ -1353,7 +1355,7 @@ public class TestEncryptionZones {
|
|
|
Arrays.asList(tokens));
|
|
|
Assert.assertEquals(2, tokens.length);
|
|
|
Assert.assertEquals(tokens[1], testToken);
|
|
|
- Assert.assertEquals(1, creds.numberOfTokens());
|
|
|
+ Assert.assertEquals(2, creds.numberOfTokens());
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -2106,22 +2108,22 @@ public class TestEncryptionZones {
|
|
|
Mockito.when(keyProvider.getConf()).thenReturn(conf);
|
|
|
byte[] testIdentifier = "Test identifier for delegation token".getBytes();
|
|
|
|
|
|
- Token<?> testToken = new Token(testIdentifier, new byte[0],
|
|
|
+ Token testToken = new Token(testIdentifier, new byte[0],
|
|
|
new Text("kms-dt"), new Text());
|
|
|
- Mockito.when(((DelegationTokenExtension) keyProvider)
|
|
|
- .addDelegationTokens(anyString(), (Credentials) any()))
|
|
|
- .thenReturn(new Token<?>[] {testToken});
|
|
|
-
|
|
|
- WebHdfsFileSystem webfsSpy = Mockito.spy(webfs);
|
|
|
- Mockito.doReturn(keyProvider).when(webfsSpy).getKeyProvider();
|
|
|
+ Mockito.when(((DelegationTokenIssuer)keyProvider).
|
|
|
+ getCanonicalServiceName()).thenReturn("service");
|
|
|
+ Mockito.when(((DelegationTokenIssuer)keyProvider).
|
|
|
+ getDelegationToken(anyString())).
|
|
|
+ thenReturn(testToken);
|
|
|
|
|
|
+ webfs.setTestProvider(keyProvider);
|
|
|
Credentials creds = new Credentials();
|
|
|
final Token<?>[] tokens =
|
|
|
- webfsSpy.addDelegationTokens("JobTracker", creds);
|
|
|
+ webfs.addDelegationTokens("JobTracker", creds);
|
|
|
|
|
|
Assert.assertEquals(2, tokens.length);
|
|
|
Assert.assertEquals(tokens[1], testToken);
|
|
|
- Assert.assertEquals(1, creds.numberOfTokens());
|
|
|
+ Assert.assertEquals(2, creds.numberOfTokens());
|
|
|
}
|
|
|
|
|
|
/**
|