Github user bitblender commented on a diff in the pull request: https://github.com/apache/drill/pull/983#discussion_r144143097 --- 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(); --- End diff -- Done.
---