smengcl commented on code in PR #11707:
URL: https://github.com/apache/ozone/pull/11707#discussion_r4357378396


##########
hadoop-ozone/client/src/test/java/org/apache/hadoop/ozone/client/rpc/TestRpcClient.java:
##########
@@ -375,6 +375,40 @@ public void testListMultipartUploadsValidatesNames(String 
volume, String bucket,
     }
   }
 
+  /**
+   * S3 Gateway serves all users with one RpcClient. A request from bob on 
another thread must not change the owner
+   * of the key that alice creates.
+   */
+  @Test
+  public void testKeyOwnerComesFromS3AuthOfCallingThread() throws Exception {
+    List<String> owners = new ArrayList<>();
+    RpcClient client = createRpcClient(new MockOmTransport() {
+      @Override
+      public OMResponse submitRequest(OMRequest request) throws IOException {
+        if (request.getCmdType() == Type.CreateKey) {
+          
owners.add(request.getCreateKeyRequest().getKeyArgs().getOwnerName());
+        }
+        return super.submitRequest(request);
+      }
+    });
+    try {
+      client.createVolume("vol1");
+      client.createBucket("vol1", "bucket1");
+      client.setThreadLocalS3Auth(new S3Auth("stringToSign", "signature", 
"alice", "alice"));
+      Thread otherRequest = new Thread(
+          () -> client.setThreadLocalS3Auth(new S3Auth("stringToSign", 
"signature", "bob", "bob")));
+      otherRequest.start();
+      otherRequest.join();
+
+      ReplicationConfig replication = 
RatisReplicationConfig.getInstance(HddsProtos.ReplicationFactor.ONE);
+      client.createKey("vol1", "bucket1", "key1", 0, replication, 
Collections.emptyMap()).close();
+      assertEquals(Collections.singletonList("alice"), owners);

Review Comment:
   nit: use AssertJ to give a clearer failure message here
   
   ```suggestion
         assertThat(owners).containsExactly("alice");
   ```



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