Skip to content

Commit

Permalink
HBASE-28106 TestShadeSaslAuthenticationProvider fails for branch-2.x (a…
Browse files Browse the repository at this point in the history
…pache#5433)

Signed-off-by: Nihal Jain <[email protected]>
(cherry picked from commit 8d91cd2)
(cherry picked from commit e8aa715)
Change-Id: I6b808870868fd5c681d0007d5976a3ea729d8e69
  • Loading branch information
Apache9 authored and petersomogyi committed Oct 2, 2023
1 parent 7f1cd29 commit 09946b1
Showing 1 changed file with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.io.BufferedWriter;
import java.io.File;
Expand All @@ -36,7 +36,6 @@
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.DoNotRetryIOException;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
Expand All @@ -49,6 +48,7 @@
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.RetriesExhaustedException;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
Expand Down Expand Up @@ -216,7 +216,7 @@ public Void run() throws Exception {
}
}

@Test(expected = DoNotRetryIOException.class)
@Test
public void testNegativeAuthentication() throws Exception {
// Validate that we can read that record back out as the user with our custom auth'n
final Configuration clientConf = new Configuration(CONF);
Expand All @@ -226,17 +226,20 @@ public void testNegativeAuthentication() throws Exception {
UserGroupInformation.createUserForTesting("user1", new String[0]);
user1.addToken(
ShadeClientTokenUtil.obtainToken(conn, "user1", "not a real password".toCharArray()));
user1.doAs(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
try (Connection conn = ConnectionFactory.createConnection(clientConf);
Table t = conn.getTable(tableName)) {
t.get(new Get(Bytes.toBytes("r1")));
fail("Should not successfully authenticate with HBase");
return null;
// Server will close the connection directly once auth failed, so at client side, we do not
// know what is the real problem so we will keep retrying, until reached the max retry times
// limitation
assertThrows("Should not successfully authenticate with HBase",
RetriesExhaustedException.class, () -> user1.doAs(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
try (Connection conn = ConnectionFactory.createConnection(clientConf);
Table t = conn.getTable(tableName)) {
t.get(new Get(Bytes.toBytes("r1")));
return null;
}
}
}
});
}));
}
}
}

0 comments on commit 09946b1

Please sign in to comment.