Commit b2d751cc authored by Enrique Alcantara's avatar Enrique Alcantara

Obtain credentials from createRole request

- Instead of passing credentials through a data object, obtain
then after the create role request is successful
parent 6640372f
......@@ -12,9 +12,6 @@ export default el => {
kubernetesIntegrationHelpPath,
accountAndExternalIdsHelpPath,
createRoleArnHelpPath,
accessKeyId,
secretAccessKey,
sessionToken,
externalId,
accountId,
instanceTypes,
......@@ -39,11 +36,6 @@ export default el => {
signOutPath,
roleArn,
},
awsCredentials: {
accessKeyId,
secretAccessKey,
sessionToken,
},
}),
components: {
CreateEksCluster,
......
import * as types from './mutation_types';
import { setAWSConfig } from '../services/aws_services_facade';
import axios from '~/lib/utils/axios_utils';
import createFlash from '~/flash';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
const getErrorMessage = data => {
const errorKey = Object.keys(data)[0];
......@@ -28,7 +30,7 @@ export const createRole = ({ dispatch, state: { createRolePath } }, payload) =>
role_arn: payload.roleArn,
role_external_id: payload.externalId,
})
.then(() => dispatch('createRoleSuccess'))
.then(({ data }) => dispatch('createRoleSuccess', convertObjectPropsToCamelCase(data)))
.catch(error => dispatch('createRoleError', { error }));
};
......@@ -36,7 +38,8 @@ export const requestCreateRole = ({ commit }) => {
commit(types.REQUEST_CREATE_ROLE);
};
export const createRoleSuccess = ({ commit }) => {
export const createRoleSuccess = ({ commit }, awsCredentials) => {
setAWSConfig({ awsCredentials });
commit(types.CREATE_ROLE_SUCCESS);
};
......
......@@ -101,6 +101,10 @@ describe('EKS Cluster Store Actions', () => {
roleArn: 'role_arn',
externalId: 'externalId',
};
const response = {
accessKeyId: 'access-key-id',
secretAccessKey: 'secret-key-id',
};
describe('when request succeeds', () => {
beforeEach(() => {
......@@ -109,7 +113,7 @@ describe('EKS Cluster Store Actions', () => {
role_arn: payload.roleArn,
role_external_id: payload.externalId,
})
.reply(201);
.reply(201, response);
});
it('dispatches createRoleSuccess action', () =>
......@@ -118,7 +122,7 @@ describe('EKS Cluster Store Actions', () => {
payload,
state,
[],
[{ type: 'requestCreateRole' }, { type: 'createRoleSuccess' }],
[{ type: 'requestCreateRole' }, { type: 'createRoleSuccess', payload: response }],
));
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment