risdenk commented on code in PR #825:
URL: https://github.com/apache/solr/pull/825#discussion_r862045344


##########
solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPI.java:
##########
@@ -198,54 +198,84 @@ public void testCreate() throws Exception {
   @Test
   public void testCreateWithTrust() throws Exception {
     String configsetName = "regular";
-    String configsetSuffix = "testCreateWithTrust";
-    String configsetSuffix2 = "testCreateWithTrust2";
-    uploadConfigSetWithAssertions(configsetName, configsetSuffix, "solr");
-    uploadConfigSetWithAssertions(configsetName, configsetSuffix2, null);
+    String trustedConfigsetSuffix = "testCreateWithTrustTrusted";
+    String untrustedConfigsetSuffix = "testCreateWithTrustUntrusted";
+    uploadConfigSetWithAssertions(configsetName, trustedConfigsetSuffix, 
"solr");
+    uploadConfigSetWithAssertions(configsetName, untrustedConfigsetSuffix, 
null);
     try (SolrZkClient zkClient =
         new SolrZkClient(
             cluster.getZkServer().getZkAddress(), AbstractZkTestCase.TIMEOUT, 
45000, null)) {
-      assertTrue(isTrusted(zkClient, configsetName, configsetSuffix));
-      assertFalse(isTrusted(zkClient, configsetName, configsetSuffix2));
+      assertTrue(isTrusted(zkClient, configsetName, trustedConfigsetSuffix));
+      assertFalse(isTrusted(zkClient, configsetName, 
untrustedConfigsetSuffix));
+      // base trusted -> untrusted
+      try {
+        ignoreException("unauthenticated request");
+        // trusted -> untrusted
+        createConfigSet(
+            null, // base is default trusted
+            "abc",
+            Collections.emptyMap(),
+            cluster.getSolrClient(),
+            null); // without username is untrusted
+        fail("Expecting exception");
+      } catch (SolrException e) {
+        assertEquals(SolrException.ErrorCode.UNAUTHORIZED.code, e.code());
+        unIgnoreException("unauthenticated request");
+      }
+      // base trusted -> untrusted
       try {
         ignoreException("unauthenticated request");
-        // trusted -> unstrusted
+        // trusted -> untrusted
         createConfigSet(
-            configsetName + configsetSuffix,
+            "_default", // base is default trusted
+            "def",
+            Collections.emptyMap(),
+            cluster.getSolrClient(),
+            null); // without username is untrusted
+        fail("Expecting exception");
+      } catch (SolrException e) {
+        assertEquals(SolrException.ErrorCode.UNAUTHORIZED.code, e.code());
+        unIgnoreException("unauthenticated request");
+      }

Review Comment:
   @epugh these two new tests check the base configset issue that was being run 
into. Adding these showed the exact same NPE error you were getting. This now 
returns the correct "unauthorized" error.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to