@@ -519,28 +519,6 @@ mocha.describe('bucketspace_fs', function() {
519519 const res = await bucketspace_fs . list_buckets ( { } , dummy_object_sdk_for_iam_account ) ;
520520 assert . equal ( res . buckets . length , 0 ) ;
521521 } ) ;
522- mocha . it ( 'list buckets - different account with bucket policy (principal by name)' , async function ( ) {
523- // another user created a bucket
524- // with bucket policy account_user3 can list it
525- const policy = generate_s3_policy ( account_user4 . name , test_bucket , [ 's3:*' ] ) . policy ;
526- const param = { name : test_bucket , policy : policy } ;
527- await bucketspace_fs . put_bucket_policy ( param ) ;
528- const dummy_object_sdk_for_iam_account = make_dummy_object_sdk_for_account ( dummy_object_sdk , account_user4 ) ;
529- const res = await bucketspace_fs . list_buckets ( { } , dummy_object_sdk_for_iam_account ) ;
530- assert . equal ( res . buckets . length , 1 ) ;
531- assert . equal ( res . buckets [ 0 ] . name . unwrap ( ) , test_bucket ) ;
532- } ) ;
533- mocha . it ( 'list buckets - different account with bucket policy (principal by id)' , async function ( ) {
534- // another user created a bucket
535- // with bucket policy account_user3 can list it
536- const policy = generate_s3_policy ( account_user4 . _id , test_bucket , [ 's3:*' ] ) . policy ;
537- const param = { name : test_bucket , policy : policy } ;
538- await bucketspace_fs . put_bucket_policy ( param ) ;
539- const dummy_object_sdk_for_iam_account = make_dummy_object_sdk_for_account ( dummy_object_sdk , account_user4 ) ;
540- const res = await bucketspace_fs . list_buckets ( { } , dummy_object_sdk_for_iam_account ) ;
541- assert . equal ( res . buckets . length , 1 ) ;
542- assert . equal ( res . buckets [ 0 ] . name . unwrap ( ) , test_bucket ) ;
543- } ) ;
544522 mocha . afterEach ( async function ( ) {
545523 await fs_utils . folder_delete ( `${ new_buckets_path } /${ test_bucket } ` ) ;
546524 const file_path = get_config_file_path ( CONFIG_SUBDIRS . BUCKETS , test_bucket ) ;
@@ -928,19 +906,54 @@ mocha.describe('bucketspace_fs', function() {
928906 } ) ;
929907
930908 mocha . describe ( 'bucket tagging operations' , function ( ) {
909+ const test_bucket_tagging = 'test-bucket-tagging' ;
910+ mocha . before ( async function ( ) {
911+ await create_bucket ( test_bucket_tagging ) ;
912+ } ) ;
913+
931914 mocha . it ( 'put_bucket_tagging' , async function ( ) {
932- const param = { name : test_bucket , tagging : [ { key : 'k1' , value : 'v1' } ] } ;
915+ const param = { name : test_bucket_tagging , tagging : [ { key : 'k1' , value : 'v1' } ] } ;
933916 await bucketspace_fs . put_bucket_tagging ( param , dummy_object_sdk ) ;
934917 const tag = await bucketspace_fs . get_bucket_tagging ( param ) ;
935918 assert . deepEqual ( tag , { tagging : param . tagging } ) ;
936919 } ) ;
937920
938921 mocha . it ( 'delete_bucket_tagging' , async function ( ) {
939- const param = { name : test_bucket } ;
922+ const param = { name : test_bucket_tagging } ;
940923 await bucketspace_fs . delete_bucket_tagging ( param ) ;
941924 const tag = await bucketspace_fs . get_bucket_tagging ( param ) ;
942925 assert . deepEqual ( tag , { tagging : [ ] } ) ;
943926 } ) ;
927+
928+ mocha . it ( 'put_bucket_tagging - different account with bucket policy (principal by name)' , async function ( ) {
929+ const policy = generate_s3_policy ( account_user4 . name , test_bucket_tagging , [ 's3:PutBucketTagging' ] ) . policy ;
930+ const param = { name : test_bucket_tagging , policy : policy } ;
931+ await bucketspace_fs . put_bucket_policy ( param ) ;
932+ const dummy_object_sdk_for_account = make_dummy_object_sdk_for_account ( dummy_object_sdk , account_user4 ) ;
933+ const tagging_param = { name : test_bucket_tagging , tagging : [ { key : 'test-key' , value : 'test-value' } ] } ;
934+ await bucketspace_fs . put_bucket_tagging ( tagging_param , dummy_object_sdk_for_account ) ;
935+ const tagging = await bucketspace_fs . get_bucket_tagging ( { name : test_bucket_tagging } ) ;
936+ assert . equal ( tagging . tagging . length , 1 ) ;
937+ assert . equal ( tagging . tagging [ 0 ] . key , 'test-key' ) ;
938+ } ) ;
939+
940+ mocha . it ( 'put_bucket_tagging - different account with bucket policy (principal by id)' , async function ( ) {
941+ const policy = generate_s3_policy ( account_user4 . _id , test_bucket_tagging , [ 's3:PutBucketTagging' ] ) . policy ;
942+ const param = { name : test_bucket_tagging , policy : policy } ;
943+ await bucketspace_fs . put_bucket_policy ( param ) ;
944+ const dummy_object_sdk_for_account = make_dummy_object_sdk_for_account ( dummy_object_sdk , account_user4 ) ;
945+ const tagging_param = { name : test_bucket_tagging , tagging : [ { key : 'test-key' , value : 'test-value' } ] } ;
946+ await bucketspace_fs . put_bucket_tagging ( tagging_param , dummy_object_sdk_for_account ) ;
947+ const tagging = await bucketspace_fs . get_bucket_tagging ( { name : test_bucket_tagging } ) ;
948+ assert . equal ( tagging . tagging . length , 1 ) ;
949+ assert . equal ( tagging . tagging [ 0 ] . key , 'test-key' ) ;
950+ } ) ;
951+
952+ mocha . after ( async function ( ) {
953+ await fs_utils . folder_delete ( `${ new_buckets_path } /${ test_bucket_tagging } ` ) ;
954+ const file_path = get_config_file_path ( CONFIG_SUBDIRS . BUCKETS , test_bucket_tagging ) ;
955+ await fs_utils . file_delete ( file_path ) ;
956+ } ) ;
944957 } ) ;
945958
946959 mocha . describe ( 'bucket lifecycle operations' , function ( ) {
0 commit comments