@@ -7,9 +7,10 @@ const path = require('path');
77const _ = require ( 'lodash' ) ;
88const mocha = require ( 'mocha' ) ;
99const assert = require ( 'assert' ) ;
10+ const SensitiveString = require ( '../../../../util/sensitive_string' ) ;
1011const fs_utils = require ( '../../../../util/fs_utils' ) ;
1112const { TMP_PATH , generate_nsfs_account, get_new_buckets_path_by_test_env, generate_iam_client,
12- require_coretest } = require ( '../../../system_tests/test_utils' ) ;
13+ require_coretest, is_nc_coretest } = require ( '../../../system_tests/test_utils' ) ;
1314const { ListUsersCommand, CreateUserCommand, GetUserCommand, UpdateUserCommand, DeleteUserCommand,
1415 ListAccessKeysCommand, CreateAccessKeyCommand, GetAccessKeyLastUsedCommand,
1516 UpdateAccessKeyCommand, DeleteAccessKeyCommand,
@@ -28,37 +29,47 @@ const IamError = require('../../../../endpoint/iam/iam_errors').IamError;
2829
2930
3031const coretest = require_coretest ( ) ;
31- const setup_options = { should_run_iam : true , https_port_iam : 7005 , debug : 5 } ;
32+ let setup_options ;
33+ if ( is_nc_coretest ) {
34+ setup_options = { should_run_iam : true , https_port_iam : 7005 , debug : 5 } ;
35+ }
3236coretest . setup ( setup_options ) ;
3337const { rpc_client, EMAIL , get_current_setup_options, stop_nsfs_process, start_nsfs_process } = coretest ;
3438
35- const CORETEST_ENDPOINT_IAM = coretest . get_iam_https_address ( ) ;
36-
37- const config_root = path . join ( TMP_PATH , 'test_nc_iam' ) ;
38- // on NC - new_buckets_path is full absolute path
39- // on Containerized - new_buckets_path is the directory
40- const new_bucket_path_param = get_new_buckets_path_by_test_env ( config_root , '/' ) ;
41-
4239let iam_account ;
40+ let account_res ;
41+ let config_root ;
4342
4443mocha . describe ( 'IAM basic integration tests - happy path' , async function ( ) {
4544 this . timeout ( 50000 ) ; // eslint-disable-line no-invalid-this
4645
4746 mocha . before ( async ( ) => {
4847 // we want to make sure that we run this test with a couple of forks (by default setup it is 0)
49- const current_setup_options = get_current_setup_options ( ) ;
50- const same_setup = _ . isEqual ( current_setup_options , setup_options ) ;
51- if ( ! same_setup ) {
52- console . log ( 'current_setup_options' , current_setup_options , 'same_setup' , same_setup ) ;
53- await stop_nsfs_process ( ) ;
54- await start_nsfs_process ( setup_options ) ;
48+ if ( is_nc_coretest ) {
49+ config_root = path . join ( TMP_PATH , 'test_nc_iam' ) ;
50+ // on NC - new_buckets_path is full absolute path
51+ // on Containerized - new_buckets_path is the directory
52+ const new_bucket_path_param = get_new_buckets_path_by_test_env ( config_root , '/' ) ;
53+
54+ const current_setup_options = get_current_setup_options ( ) ;
55+ const same_setup = _ . isEqual ( current_setup_options , setup_options ) ;
56+ if ( ! same_setup ) {
57+ console . log ( 'current_setup_options' , current_setup_options , 'same_setup' , same_setup ) ;
58+ await stop_nsfs_process ( ) ;
59+ await start_nsfs_process ( setup_options ) ;
60+ }
61+ await fs_utils . create_fresh_path ( new_bucket_path_param ) ;
62+ await fs_utils . file_must_exist ( new_bucket_path_param ) ;
63+ account_res = await generate_nsfs_account ( rpc_client , EMAIL , new_bucket_path_param , { admin : true } ) ;
64+ } else {
65+ account_res = ( await rpc_client . account . read_account ( { email : EMAIL } ) ) . access_keys [ 0 ] ;
5566 }
5667
5768 // needed details for creating the account (and then the client)
58- await fs_utils . create_fresh_path ( new_bucket_path_param ) ;
59- await fs_utils . file_must_exist ( new_bucket_path_param ) ;
60- const res = await generate_nsfs_account ( rpc_client , EMAIL , new_bucket_path_param , { admin : true } ) ;
61- iam_account = generate_iam_client ( res . access_key , res . secret_key , CORETEST_ENDPOINT_IAM ) ;
69+ const coretest_endpoint_iam = coretest . get_https_address_iam ( ) ;
70+ const access_key = account_res . access_key instanceof SensitiveString ? account_res . access_key . unwrap ( ) : account_res . access_key ;
71+ const secret_key = account_res . secret_key instanceof SensitiveString ? account_res . secret_key . unwrap ( ) : account_res . secret_key ;
72+ iam_account = generate_iam_client ( access_key , secret_key , coretest_endpoint_iam ) ;
6273 } ) ;
6374
6475 mocha . after ( async ( ) => {
@@ -196,6 +207,8 @@ mocha.describe('IAM basic integration tests - happy path', async function() {
196207 } ) ;
197208
198209 mocha . it ( 'get access key (last used)' , async function ( ) {
210+ // Skipping for containerized noobaa
211+ if ( ! is_nc_coretest ) this . skip ( ) ; // eslint-disable-line no-invalid-this
199212 const input = {
200213 AccessKeyId : access_key_id
201214 } ;
0 commit comments