accumulo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From keith-turner <...@git.apache.org>
Subject [GitHub] accumulo pull request #273: ACCUMULO-4665 Use UGI with real Kerberos credent...
Date Mon, 26 Jun 2017 20:52:36 GMT
Github user keith-turner commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/273#discussion_r124117442
  
    --- Diff: test/src/test/java/org/apache/accumulo/test/functional/KerberosProxyIT.java
---
    @@ -463,6 +477,56 @@ public void testMismatchPrincipals() throws Exception {
         }
       }
     
    +  @Test
    +  public void proxiedUserAccessWithoutAccumuloProxy() throws Exception {
    +    final String tableName = getUniqueNames(1)[0];
    +    ClusterUser rootUser = kdc.getRootUser();
    +    final UserGroupInformation rootUgi = UserGroupInformation.loginUserFromKeytabAndReturnUGI(rootUser.getPrincipal(),
rootUser.getKeytab().getAbsolutePath());
    +    final UserGroupInformation realUgi = UserGroupInformation.loginUserFromKeytabAndReturnUGI(proxyPrincipal,
proxyKeytab.getAbsolutePath());
    +    final String userWithoutCredentials = kdc.qualifyUser(PROXIED_USER);
    +    final UserGroupInformation proxyUser = UserGroupInformation.createProxyUser(userWithoutCredentials,
realUgi);
    +
    +    // Create a table and user, grant permission to our user to read that table.
    +    rootUgi.doAs(new PrivilegedExceptionAction<Void>() {
    +      @Override
    +      public Void run() throws Exception {
    +        ZooKeeperInstance inst = new ZooKeeperInstance(mac.getClientConfig());
    +        Connector conn = inst.getConnector(rootUgi.getUserName(), new KerberosToken());
    +        conn.tableOperations().create(tableName);
    +        conn.securityOperations().createLocalUser(userWithoutCredentials, new PasswordToken("ignored"));
    +        conn.securityOperations().grantTablePermission(userWithoutCredentials, tableName,
TablePermission.READ);
    +        return null;
    +      }
    +    });
    +    realUgi.doAs(new PrivilegedExceptionAction<Void>() {
    +      @Override
    +      public Void run() throws Exception {
    +        ZooKeeperInstance inst = new ZooKeeperInstance(mac.getClientConfig());
    +        Connector conn = inst.getConnector(proxyPrincipal, new KerberosToken());
    +        try {
    +          Scanner s = conn.createScanner(tableName, Authorizations.EMPTY);
    +          s.iterator().hasNext();
    +          Assert.fail("Expected to see an exception");
    +        } catch (RuntimeException e) {
    +          int numSecurityExceptionsSeen = Iterables.size(Iterables.filter(Throwables.getCausalChain(e),
    +              org.apache.accumulo.core.client.AccumuloSecurityException.class));
    +          assertTrue("Expected to see at least one AccumuloSecurityException, but saw:
" + Throwables.getStackTraceAsString(e), numSecurityExceptionsSeen > 0);
    +        }
    +        return null;
    +      }
    +    });
    +    proxyUser.doAs(new PrivilegedExceptionAction<Void>() {
    +      @Override
    +      public Void run() throws Exception {
    +        ZooKeeperInstance inst = new ZooKeeperInstance(mac.getClientConfig());
    +        Connector conn = inst.getConnector(userWithoutCredentials, new KerberosToken(userWithoutCredentials));
    +        Scanner s = conn.createScanner(tableName, Authorizations.EMPTY);
    +        assertFalse(s.iterator().hasNext());
    +        return null;
    --- End diff --
    
    seems like `return null` could be omitted


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message