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_r281024273
########## 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)) { Review comment: This corresponds to https://github.com/apache/storm/pull/2990/files#diff-a48145dd5bbd83aced6dd85b1d85ec64L343 to https://github.com/apache/storm/pull/2990/files#diff-a48145dd5bbd83aced6dd85b1d85ec64L373 ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services