srdo commented on a change in pull request #2990: STORM-3372: Fix NPE when
shutting down HFSSpout, fix storm-hdfs tests…
URL: https://github.com/apache/storm/pull/2990#discussion_r281024326
##########
File path:
external/storm-hdfs-blobstore/src/test/java/org/apache/storm/hdfs/blobstore/BlobStoreTest.java
##########
@@ -289,133 +280,130 @@ public void testReplication(String path, BlobStore
store)
store.deleteBlob("test", getSubject(createSubject));
}
- public Subject getSubject(String name) {
+ public static Subject getSubject(String name) {
Subject subject = new Subject();
SingleUserPrincipal user = new SingleUserPrincipal(name);
subject.getPrincipals().add(user);
return subject;
}
-
- // Check for Blobstore with authentication
- public void testWithAuthentication(BlobStore store)
- throws Exception {
- //Test for Nimbus Admin
- Subject admin = getSubject("admin");
- assertStoreHasExactly(store);
- SettableBlobMeta metadata = new
SettableBlobMeta(BlobStoreAclHandler.DEFAULT);
- try (AtomicOutputStream out = store.createBlob("test", metadata,
admin)) {
- assertStoreHasExactly(store, "test");
- out.write(1);
+
+ static enum AuthenticationTestSubject {
+ //Nimbus Admin
+ ADMIN(getSubject("admin")),
+ //Nimbus groups admin
+ ADMIN_GROUPS_USER(getSubject("adminGroupsUser")),
+ //Supervisor admin
+ SUPERVISOR(getSubject("supervisor")),
+ //Nimbus itself
+ NIMBUS(getNimbusSubject());
+
+ private Subject subject;
+
+ private AuthenticationTestSubject(Subject subject) {
+ this.subject = subject;
}
- store.deleteBlob("test", admin);
-
- //Test for Nimbus Groups Admin
- Subject adminsGroupsUser = getSubject("adminsGroupsUser");
- assertStoreHasExactly(store);
- metadata = new SettableBlobMeta(BlobStoreAclHandler.DEFAULT);
- try (AtomicOutputStream out = store.createBlob("test", metadata,
adminsGroupsUser)) {
- assertStoreHasExactly(store, "test");
- out.write(1);
+ }
+
+ @ParameterizedTest
+ @EnumSource(value = AuthenticationTestSubject.class)
+ void testWithAuthentication(AuthenticationTestSubject testSubject) throws
Exception {
+ try (AutoCloseableBlobStoreContainer container =
initHdfs("/storm/blobstore-auth-" + testSubject.name())) {
+ BlobStore store = container.blobStore;
+ assertStoreHasExactly(store);
+ SettableBlobMeta metadata = new
SettableBlobMeta(BlobStoreAclHandler.DEFAULT);
+ try (AtomicOutputStream out = store.createBlob("test", metadata,
testSubject.subject)) {
+ assertStoreHasExactly(store, "test");
+ out.write(1);
+ }
+ store.deleteBlob("test", testSubject.subject);
}
- store.deleteBlob("test", adminsGroupsUser);
-
- //Test for Supervisor Admin
- Subject supervisor = getSubject("supervisor");
- assertStoreHasExactly(store);
- metadata = new SettableBlobMeta(BlobStoreAclHandler.DEFAULT);
- try (AtomicOutputStream out = store.createBlob("test", metadata,
supervisor)) {
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testWithAuthenticationDummy(boolean securityEnabled) throws Exception
{
+ try (AutoCloseableBlobStoreContainer container =
initHdfs("/storm/blobstore-auth-dummy-sec-" + securityEnabled)) {
+ BlobStore store = container.blobStore;
+ Subject who = getSubject("test_subject");
+ assertStoreHasExactly(store);
+
+ // Tests for case when subject != null (security turned on) and
+ // acls for the blob are set to WORLD_EVERYTHING
+ SettableBlobMeta metadata = new SettableBlobMeta(securityEnabled ?
BlobStoreAclHandler.DEFAULT : BlobStoreAclHandler.WORLD_EVERYTHING);
+ try (AtomicOutputStream out = store.createBlob("test", metadata,
who)) {
+ out.write(1);
+ }
assertStoreHasExactly(store, "test");
- out.write(1);
+ if (securityEnabled) {
+ // Testing whether acls are set to WORLD_EVERYTHING. Here the
acl should not contain WORLD_EVERYTHING because
+ // the subject is neither null nor empty. The ACL should
however contain USER_EVERYTHING as user needs to have
+ // complete access to the blob
+ assertTrue("ACL contains WORLD_EVERYTHING",
!metadata.toString().contains("AccessControl(type:OTHER, access:7)"));
+ } else {
+ // Testing whether acls are set to WORLD_EVERYTHING
+ assertTrue("ACL does not contain WORLD_EVERYTHING",
metadata.toString().contains("AccessControl(type:OTHER, access:7)"));
+ }
+
+ readAssertEqualsWithAuth(store, who, "test", 1);
+
+ LOG.info("Deleting test");
+ store.deleteBlob("test", who);
+ assertStoreHasExactly(store);
}
- store.deleteBlob("test", supervisor);
-
- //Test for Nimbus itself as a user
- Subject nimbus = getNimbusSubject();
- assertStoreHasExactly(store);
- metadata = new SettableBlobMeta(BlobStoreAclHandler.DEFAULT);
- try (AtomicOutputStream out = store.createBlob("test", metadata,
nimbus)) {
+ }
+
+ @Test
+ void testWithAuthenticationUpdate() throws Exception {
+ try (AutoCloseableBlobStoreContainer container =
initHdfs("/storm/blobstore-auth-update")) {
Review comment:
This is
https://github.com/apache/storm/pull/2990/files#diff-a48145dd5bbd83aced6dd85b1d85ec64L376
to
https://github.com/apache/storm/pull/2990/files#diff-a48145dd5bbd83aced6dd85b1d85ec64L389
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services