]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
test/rgw/pubsub: test persistent notifications with account user
authorCasey Bodley <cbodley@redhat.com>
Wed, 3 Apr 2024 22:21:20 +0000 (18:21 -0400)
committerCasey Bodley <cbodley@redhat.com>
Fri, 12 Apr 2024 19:34:30 +0000 (15:34 -0400)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 43ca67b3d88d900abd6aaa52e84d46d212a936c6)

src/test/rgw/bucket_notification/test_bn.py

index c613c851399ccd9445efb086cf27c9c45642c000..5003127fedf57e5970dfb5e17bd107e567cf3815 100644 (file)
@@ -478,17 +478,22 @@ def connection2():
     return conn
 
 
-def another_user(tenant=None):
+def another_user(user=None, tenant=None, account=None):
     access_key = str(time.time())
     secret_key = str(time.time())
-    uid = UID_PREFIX + str(time.time())
+    uid = user or UID_PREFIX + str(time.time())
+    cmd = ['user', 'create', '--uid', uid, '--access-key', access_key, '--secret-key', secret_key, '--display-name', 'Superman']
+    arn = f'arn:aws:iam:::user/{uid}'
     if tenant:
-        _, result = admin(['user', 'create', '--uid', uid, '--tenant', tenant, '--access-key', access_key, '--secret-key', secret_key, '--display-name', '"Super Man"'], get_config_cluster())
-    else:
-        _, result = admin(['user', 'create', '--uid', uid, '--access-key', access_key, '--secret-key', secret_key, '--display-name', '"Super Man"'], get_config_cluster())
-    arn = f'arn:aws:iam::{tenant or ""}:user/{uid}'
+        cmd += ['--tenant', tenant]
+        arn = f'arn:aws:iam::{tenant}:user/{uid}'
+    if account:
+        cmd += ['--account-id', account, '--account-root']
+        arn = f'arn:aws:iam::{account}:user/Superman'
 
+    _, result = admin(cmd, get_config_cluster())
     assert_equal(result, 0)
+
     conn = S3Connection(aws_access_key_id=access_key,
                   aws_secret_access_key=secret_key,
                       is_secure=False, port=get_config_port(), host=get_config_host(), 
@@ -3800,9 +3805,8 @@ def test_ps_s3_persistent_multiple_endpoints():
     conn.delete_bucket(bucket_name)
     http_server.close()
 
-def persistent_notification(endpoint_type):
+def persistent_notification(endpoint_type, conn):
     """ test pushing persistent notification """
-    conn = connection()
     zonegroup = get_config_zonegroup()
 
     # create bucket
@@ -3907,19 +3911,38 @@ def persistent_notification(endpoint_type):
 @attr('http_test')
 def test_ps_s3_persistent_notification_http():
     """ test pushing persistent notification http """
-    persistent_notification('http')
+    conn = connection()
+    persistent_notification('http', conn)
+
+@attr('http_test')
+def test_ps_s3_persistent_notification_http_account():
+    """ test pushing persistent notification via http for account user """
 
+    account = 'RGW77777777777777777'
+    user = UID_PREFIX + 'test'
+
+    _, result = admin(['account', 'create', '--account-id', account, '--account-name', 'testacct'], get_config_cluster())
+    assert_equal(result, 0)
+
+    conn, _ = another_user(user=user, account=account)
+    try:
+        persistent_notification('http', conn)
+    finally:
+        admin(['user', 'rm', '--uid', user], get_config_cluster())
+        admin(['account', 'rm', '--account-id', account], get_config_cluster())
 
 @attr('amqp_test')
 def test_ps_s3_persistent_notification_amqp():
     """ test pushing persistent notification amqp """
-    persistent_notification('amqp')
+    conn = connection()
+    persistent_notification('amqp', conn)
 
 
 @attr('kafka_test')
 def test_ps_s3_persistent_notification_kafka():
     """ test pushing persistent notification kafka """
-    persistent_notification('kafka')
+    conn = connection()
+    persistent_notification('kafka', conn)
 
 
 def random_string(length):