Skip to content

Commit

Permalink
fix: headless auth required attributes must be an array (aws-amplify#…
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardfoyle authored and Ross Ragsdale committed Nov 19, 2020
1 parent c9bc207 commit d17e67b
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable max-len */

const coreQuestions = require('../../provider-utils/awscloudformation/question-factories/core-questions');
const defaults = require('../../provider-utils/awscloudformation/assets/cognito-defaults');
const maps = require('../../provider-utils/awscloudformation/assets/string-maps');
const coreQuestions = require('../../../../provider-utils/awscloudformation/question-factories/core-questions');
const defaults = require('../../../../provider-utils/awscloudformation/assets/cognito-defaults');
const maps = require('../../../../provider-utils/awscloudformation/assets/string-maps');

const defaultFileName = 'cognito-defaults';
const stringMapFileName = 'string-maps';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`get add auth request adaptor valid translations translates request with minimal user pool config only 1`] = `
Object {
"adminQueries": false,
"adminQueryGroup": undefined,
"authProviders": Array [],
"authSelections": "userPoolOnly",
"autoVerifiedAttributes": Array [],
"identityPoolName": undefined,
"mfaConfiguration": "OFF",
"requiredAttributes": Array [
"email",
],
"resourceName": "myTestAuth",
"serviceName": "Cognito",
"thirdPartyAuth": false,
"updateFlow": "manual",
"useDefault": "manual",
"userPoolGroupList": Array [],
"userPoolGroups": false,
"userPoolName": undefined,
"usernameAttributes": Array [
"email",
],
"userpoolClientReadAttributes": Array [],
"userpoolClientRefreshTokenValidity": undefined,
"userpoolClientWriteAttributes": Array [],
}
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { AddAuthRequest, CognitoUserPoolSigninMethod, CognitoUserProperty } from 'amplify-headless-interface';
import { getAddAuthRequestAdaptor } from '../../../../provider-utils/awscloudformation/utils/auth-request-adaptors';

describe('get add auth request adaptor', () => {
describe('valid translations', () => {
it('translates request with minimal user pool config only', () => {
const addAuthRequest: AddAuthRequest = {
version: 1,
resourceName: 'myTestAuth',
serviceConfiguration: {
serviceName: 'Cognito',
userPoolConfiguration: {
signinMethod: CognitoUserPoolSigninMethod.EMAIL,
requiredSignupAttributes: [CognitoUserProperty.EMAIL],
},
includeIdentityPool: false,
},
};

expect(getAddAuthRequestAdaptor('javascript')(addAuthRequest)).toMatchSnapshot();
});
});
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { handleTriggers } = require('../../provider-utils/awscloudformation/utils/trigger-flow-auth-helper');
const { handleTriggers } = require('../../../../provider-utils/awscloudformation/utils/trigger-flow-auth-helper');

const defaults = {
envVars: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface ServiceQuestionsBaseResult {
requiredAttributes: string[];
authSelections: 'userPoolOnly' | 'identityPoolAndUserPool';
userPoolName?: string;
usernameAttributes?: UsernameAttributes;
usernameAttributes?: UsernameAttributes[];
userPoolGroups: boolean;
userPoolGroupList?: string[];
userpoolClientRefreshTokenValidity?: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const getUpdateAuthRequestAdaptor = (projectType: string, requiredAttribu
const immutableAttributeAdaptor = (userPoolConfig: CognitoUserPoolConfiguration, identityPoolConfig?: CognitoIdentityPoolConfiguration) => {
return {
userPoolName: userPoolConfig.userPoolName,
usernameAttributes: signinAttributeMap[userPoolConfig.signinMethod],
usernameAttributes: [signinAttributeMap[userPoolConfig.signinMethod]],
...immutableIdentityPoolMap(identityPoolConfig),
};
};
Expand Down

0 comments on commit d17e67b

Please sign in to comment.