drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paul-rogers <...@git.apache.org>
Subject [GitHub] drill pull request #983: MD-2769: DRILL-5819: Default value of security.admi...
Date Wed, 11 Oct 2017 04:40:42 GMT
Github user paul-rogers commented on a diff in the pull request:

    https://github.com/apache/drill/pull/983#discussion_r143910712
  
    --- Diff: exec/java-exec/src/test/java/org/apache/drill/exec/server/TestOptionsAuthEnabled.java
---
    @@ -115,4 +124,59 @@ private void setOptHelper() throws Exception {
           test(String.format("ALTER SYSTEM SET `%s` = %d;", ExecConstants.SLICE_TARGET, ExecConstants.SLICE_TARGET_DEFAULT));
         }
       }
    +
    +  @Test
    +  public void testAdminUserOptions() throws Exception {
    +    FixtureBuilder builder = ClusterFixture.builder();
    +
    +    try (ClusterFixture cluster = builder.build();
    +         ClientFixture client = cluster.clientFixture()) {
    +      OptionManager optionManager = cluster.drillbit().getContext().getOptionManager();
    +
    +      // Admin Users Tests
    +      // config file should have the 'fake' default admin user and it should be returned
    +      // by the option manager if the option has not been set by the user
    +      String configAdminUser =  optionManager.getOption(ExecConstants.ADMIN_USERS_VALIDATOR);;
    +      assertEquals(configAdminUser, ExecConstants.ADMIN_USERS_VALIDATOR.DEFAULT_ADMIN_USERS);
    +
    +      // Option accessor should never return the 'fake' default from the config
    +      String adminUser1 = ExecConstants.ADMIN_USERS_VALIDATOR.getAdminUsers(optionManager);
    +      assertNotEquals(adminUser1, ExecConstants.ADMIN_USERS_VALIDATOR.DEFAULT_ADMIN_USERS);
    +
    +      // Change TEST_ADMIN_USER if necessary
    +      String TEST_ADMIN_USER = "ronswanson";
    +      if (adminUser1.equals(TEST_ADMIN_USER)) {
    +        TEST_ADMIN_USER += "thefirst";
    +      }
    +      // Check if the admin option accessor honors a user-supplied values
    +      String sql = String.format("ALTER SYSTEM SET `%s`='%s'", ExecConstants.ADMIN_USERS_KEY,
TEST_ADMIN_USER);
    +      client.queryBuilder().sql(sql).run();
    +      String adminUser2 = ExecConstants.ADMIN_USERS_VALIDATOR.getAdminUsers(optionManager);
    +      assertEquals(adminUser2, TEST_ADMIN_USER);
    +
    +      // Admin User Groups Tests
    +
    +      // config file should have the 'fake' default admin user and it should be returned
    +      // by the option manager if the option has not been set by the user
    +      String configAdminUserGroups =  optionManager.getOption(ExecConstants.ADMIN_USER_GROUPS_VALIDATOR);
    +      assertEquals(configAdminUserGroups, ExecConstants.ADMIN_USER_GROUPS_VALIDATOR.DEFAULT_ADMIN_USER_GROUPS);
    +
    +      // Option accessor should never return the 'fake' default from the config
    +      String adminUserGroups1 = ExecConstants.ADMIN_USER_GROUPS_VALIDATOR.getAdminUserGroups(optionManager);
    +      assertNotEquals(adminUserGroups1, ExecConstants.ADMIN_USER_GROUPS_VALIDATOR.DEFAULT_ADMIN_USER_GROUPS);
    +
    +      // Change TEST_ADMIN_USER_GROUPS if necessary
    +      String TEST_ADMIN_USER_GROUPS = "yakshavers";
    +      if (adminUserGroups1.equals(TEST_ADMIN_USER_GROUPS)) {
    +        TEST_ADMIN_USER_GROUPS += ",wormracers";
    --- End diff --
    
    Usually ALL_CAPS is reserved for constants, which means we can't alter them as we do here...
I suspect you mean `testAdminUserGroups`...


---

Mime
View raw message