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 => { ...@@ -12,9 +12,6 @@ export default el => {
kubernetesIntegrationHelpPath, kubernetesIntegrationHelpPath,
accountAndExternalIdsHelpPath, accountAndExternalIdsHelpPath,
createRoleArnHelpPath, createRoleArnHelpPath,
accessKeyId,
secretAccessKey,
sessionToken,
externalId, externalId,
accountId, accountId,
instanceTypes, instanceTypes,
...@@ -39,11 +36,6 @@ export default el => { ...@@ -39,11 +36,6 @@ export default el => {
signOutPath, signOutPath,
roleArn, roleArn,
}, },
awsCredentials: {
accessKeyId,
secretAccessKey,
sessionToken,
},
}), }),
components: { components: {
CreateEksCluster, CreateEksCluster,
......
import * as types from './mutation_types'; import * as types from './mutation_types';
import { setAWSConfig } from '../services/aws_services_facade';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
const getErrorMessage = data => { const getErrorMessage = data => {
const errorKey = Object.keys(data)[0]; const errorKey = Object.keys(data)[0];
...@@ -28,7 +30,7 @@ export const createRole = ({ dispatch, state: { createRolePath } }, payload) => ...@@ -28,7 +30,7 @@ export const createRole = ({ dispatch, state: { createRolePath } }, payload) =>
role_arn: payload.roleArn, role_arn: payload.roleArn,
role_external_id: payload.externalId, role_external_id: payload.externalId,
}) })
.then(() => dispatch('createRoleSuccess')) .then(({ data }) => dispatch('createRoleSuccess', convertObjectPropsToCamelCase(data)))
.catch(error => dispatch('createRoleError', { error })); .catch(error => dispatch('createRoleError', { error }));
}; };
...@@ -36,7 +38,8 @@ export const requestCreateRole = ({ commit }) => { ...@@ -36,7 +38,8 @@ export const requestCreateRole = ({ commit }) => {
commit(types.REQUEST_CREATE_ROLE); commit(types.REQUEST_CREATE_ROLE);
}; };
export const createRoleSuccess = ({ commit }) => { export const createRoleSuccess = ({ commit }, awsCredentials) => {
setAWSConfig({ awsCredentials });
commit(types.CREATE_ROLE_SUCCESS); commit(types.CREATE_ROLE_SUCCESS);
}; };
......
...@@ -101,6 +101,10 @@ describe('EKS Cluster Store Actions', () => { ...@@ -101,6 +101,10 @@ describe('EKS Cluster Store Actions', () => {
roleArn: 'role_arn', roleArn: 'role_arn',
externalId: 'externalId', externalId: 'externalId',
}; };
const response = {
accessKeyId: 'access-key-id',
secretAccessKey: 'secret-key-id',
};
describe('when request succeeds', () => { describe('when request succeeds', () => {
beforeEach(() => { beforeEach(() => {
...@@ -109,7 +113,7 @@ describe('EKS Cluster Store Actions', () => { ...@@ -109,7 +113,7 @@ describe('EKS Cluster Store Actions', () => {
role_arn: payload.roleArn, role_arn: payload.roleArn,
role_external_id: payload.externalId, role_external_id: payload.externalId,
}) })
.reply(201); .reply(201, response);
}); });
it('dispatches createRoleSuccess action', () => it('dispatches createRoleSuccess action', () =>
...@@ -118,7 +122,7 @@ describe('EKS Cluster Store Actions', () => { ...@@ -118,7 +122,7 @@ describe('EKS Cluster Store Actions', () => {
payload, payload,
state, 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