@@ -217,8 +217,6 @@ mocha.describe('IAM integration tests', async function() {
217217 } ) ;
218218
219219 mocha . it ( 'get access key (last used)' , async function ( ) {
220- // Skipping for containerized noobaa
221- if ( ! is_nc_coretest ) this . skip ( ) ; // eslint-disable-line no-invalid-this
222220 const input = {
223221 AccessKeyId : access_key_id
224222 } ;
@@ -1057,6 +1055,39 @@ mocha.describe('IAM integration tests', async function() {
10571055 } ) ;
10581056
10591057 } ) ;
1058+
1059+ mocha . describe ( 'IAM Access Keys API' , async function ( ) {
1060+ const username2 = 'Alejandro' ;
1061+ let access_key_id ;
1062+
1063+ mocha . describe ( 'IAM GetAccessKeyLastUsed API' , async function ( ) {
1064+ mocha . before ( async ( ) => {
1065+ await create_iam_user ( username2 ) ;
1066+ const res = await create_access_key_iam_user ( username2 ) ;
1067+ access_key_id = res . access_key_id ;
1068+ } ) ;
1069+
1070+ mocha . after ( async ( ) => {
1071+ await delete_access_key_iam_user ( access_key_id , username2 ) ;
1072+ await delete_iam_user ( username2 ) ;
1073+ } ) ;
1074+
1075+ mocha . it ( 'get access key last used with invalid access key ID should fail' , async function ( ) {
1076+ const access_key_id_invalid = access_key_id + '0' ;
1077+ try {
1078+ const input = {
1079+ AccessKeyId : access_key_id_invalid
1080+ } ;
1081+ const command = new GetAccessKeyLastUsedCommand ( input ) ;
1082+ await iam_account . send ( command ) ;
1083+ assert . fail ( 'get access key last used with invalid access key ID - should throw an error' ) ;
1084+ } catch ( err ) {
1085+ const err_code = err . Error . Code ;
1086+ assert . equal ( err_code , IamError . NoSuchEntity . code ) ;
1087+ }
1088+ } ) ;
1089+ } ) ;
1090+ } ) ;
10601091 } ) ;
10611092} ) ;
10621093
@@ -1095,3 +1126,36 @@ async function delete_iam_user(username_to_delete) {
10951126 const response = await iam_account . send ( command ) ;
10961127 _check_status_code_ok ( response ) ;
10971128}
1129+
1130+
1131+ /**
1132+ * Create an IAM user's access key with the given username.
1133+ * use this function for before/after hooks to avoid code duplication
1134+ * @param {string } username
1135+ */
1136+ async function create_access_key_iam_user ( username ) {
1137+ const input = {
1138+ UserName : username
1139+ } ;
1140+ const command = new CreateAccessKeyCommand ( input ) ;
1141+ const response = await iam_account . send ( command ) ;
1142+ _check_status_code_ok ( response ) ;
1143+ return { access_key_id : response . AccessKey . AccessKeyId , secret_access_key : response . AccessKey . SecretAccessKey } ;
1144+ }
1145+
1146+
1147+ /**
1148+ * Delete an IAM user's access key with the given access key ID and username.
1149+ * use this function for before/after hooks to avoid code duplication
1150+ * @param {string } access_key_to_delete
1151+ * @param {string } username
1152+ */
1153+ async function delete_access_key_iam_user ( access_key_to_delete , username ) {
1154+ const input = {
1155+ UserName : username ,
1156+ AccessKeyId : access_key_to_delete
1157+ } ;
1158+ const command = new DeleteAccessKeyCommand ( input ) ;
1159+ const response = await iam_account . send ( command ) ;
1160+ _check_status_code_ok ( response ) ;
1161+ }
0 commit comments