use of com.squareup.okhttp.mockwebserver.MockResponse in project hadoop by apache.
the class TestCustomTokenProvider method testCustomTokenManagement.
@Test
public void testCustomTokenManagement() throws IOException, URISyntaxException {
int accessTokenCallbackDuringExec = 0;
init();
for (TestableAdlFileSystem tfs : fileSystems) {
for (int i = 0; i < backendCallCount; ++i) {
getMockServer().enqueue(new MockResponse().setResponseCode(200).setBody(TestADLResponseData.getGetFileStatusJSONResponse()));
FileStatus fileStatus = tfs.getFileStatus(new Path("/test1/test2"));
Assert.assertTrue(fileStatus.isFile());
Assert.assertEquals("adl://" + getMockServer().getHostName() + ":" + getMockServer().getPort() + "/test1/test2", fileStatus.getPath().toString());
Assert.assertEquals(4194304, fileStatus.getLen());
Assert.assertEquals(ADL_BLOCK_SIZE, fileStatus.getBlockSize());
Assert.assertEquals(1, fileStatus.getReplication());
Assert.assertEquals(new FsPermission("777"), fileStatus.getPermission());
Assert.assertEquals("NotSupportYet", fileStatus.getOwner());
Assert.assertEquals("NotSupportYet", fileStatus.getGroup());
}
accessTokenCallbackDuringExec += ((CustomMockTokenProvider) tfs.getAzureTokenProvider()).getAccessTokenRequestCount();
}
Assert.assertEquals(expectedCallbackToAccessToken, accessTokenCallbackDuringExec);
}
use of com.squareup.okhttp.mockwebserver.MockResponse in project hadoop by apache.
the class TestACLFeatures method getAclStatusAsExpected.
@Test
public void getAclStatusAsExpected() throws URISyntaxException, IOException {
getMockServer().enqueue(new MockResponse().setResponseCode(200).setBody(TestADLResponseData.getGetAclStatusJSONResponse()));
AclStatus aclStatus = getMockAdlFileSystem().getAclStatus(new Path("/test1/test2"));
Assert.assertEquals(aclStatus.getGroup(), "supergroup");
Assert.assertEquals(aclStatus.getOwner(), "hadoop");
Assert.assertEquals((Short) aclStatus.getPermission().toShort(), Short.valueOf("775", 8));
for (AclEntry entry : aclStatus.getEntries()) {
if (!(entry.toString().equalsIgnoreCase("user:carla:rw-") || entry.toString().equalsIgnoreCase("group::r-x"))) {
Assert.fail("Unexpected entry : " + entry.toString());
}
}
}
use of com.squareup.okhttp.mockwebserver.MockResponse in project hadoop by apache.
the class TestACLFeatures method getAclStatusNotExists.
@Test(expected = FileNotFoundException.class)
public void getAclStatusNotExists() throws URISyntaxException, IOException {
getMockServer().enqueue(new MockResponse().setResponseCode(404).setBody(TestADLResponseData.getFileNotFoundException()));
getMockAdlFileSystem().getAclStatus(new Path("/test1/test2"));
}
use of com.squareup.okhttp.mockwebserver.MockResponse in project hadoop by apache.
the class TestACLFeatures method testModifyAclEntries.
@Test(expected = AccessControlException.class)
public void testModifyAclEntries() throws URISyntaxException, IOException {
getMockServer().enqueue(new MockResponse().setResponseCode(200));
List<AclEntry> entries = new ArrayList<AclEntry>();
AclEntry.Builder aclEntryBuilder = new AclEntry.Builder();
aclEntryBuilder.setName("hadoop");
aclEntryBuilder.setType(AclEntryType.USER);
aclEntryBuilder.setPermission(FsAction.ALL);
aclEntryBuilder.setScope(AclEntryScope.ACCESS);
entries.add(aclEntryBuilder.build());
aclEntryBuilder.setName("hdfs");
aclEntryBuilder.setType(AclEntryType.GROUP);
aclEntryBuilder.setPermission(FsAction.READ_WRITE);
aclEntryBuilder.setScope(AclEntryScope.DEFAULT);
entries.add(aclEntryBuilder.build());
getMockAdlFileSystem().modifyAclEntries(new Path("/test1/test2"), entries);
getMockServer().enqueue(new MockResponse().setResponseCode(403).setBody(TestADLResponseData.getAccessControlException()));
getMockAdlFileSystem().modifyAclEntries(new Path("/test1/test2"), entries);
}
use of com.squareup.okhttp.mockwebserver.MockResponse in project hadoop by apache.
the class TestACLFeatures method testRemoveAclEntries.
@Test(expected = AccessControlException.class)
public void testRemoveAclEntries() throws URISyntaxException, IOException {
getMockServer().enqueue(new MockResponse().setResponseCode(200));
List<AclEntry> entries = new ArrayList<AclEntry>();
AclEntry.Builder aclEntryBuilder = new AclEntry.Builder();
aclEntryBuilder.setName("hadoop");
aclEntryBuilder.setType(AclEntryType.USER);
aclEntryBuilder.setPermission(FsAction.ALL);
aclEntryBuilder.setScope(AclEntryScope.ACCESS);
entries.add(aclEntryBuilder.build());
aclEntryBuilder.setName("hdfs");
aclEntryBuilder.setType(AclEntryType.GROUP);
aclEntryBuilder.setPermission(FsAction.READ_WRITE);
aclEntryBuilder.setScope(AclEntryScope.DEFAULT);
entries.add(aclEntryBuilder.build());
getMockAdlFileSystem().removeAclEntries(new Path("/test1/test2"), entries);
getMockServer().enqueue(new MockResponse().setResponseCode(403).setBody(TestADLResponseData.getAccessControlException()));
getMockAdlFileSystem().removeAclEntries(new Path("/test1/test2"), entries);
}
Aggregations