Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(getUser&adminGetUser): username field now returns sub... #335

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions integration-tests/aws-sdk/adminDeleteUser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ClockFake } from "../../src/__tests__/clockFake";
import { UUID } from "../../src/__tests__/patterns";
import { UserNotFoundError } from "../../src/errors";
import { withCognitoSdk } from "./setup";
import { attributeValue } from "../../src/services/userPoolService";

const currentDate = new Date();
const roundedDate = new Date(currentDate.getTime());
Expand Down Expand Up @@ -38,7 +39,7 @@ describe(
UserAttributes: createUserResult.User?.Attributes,
UserCreateDate: createUserResult.User?.UserCreateDate,
UserLastModifiedDate: createUserResult.User?.UserLastModifiedDate,
Username: createUserResult.User?.Username,
Username: attributeValue("sub", createUserResult.User?.Attributes),
UserStatus: createUserResult.User?.UserStatus,
});

Expand Down Expand Up @@ -89,7 +90,7 @@ describe(
UserAttributes: createUserResult.User?.Attributes,
UserCreateDate: createUserResult.User?.UserCreateDate,
UserLastModifiedDate: createUserResult.User?.UserLastModifiedDate,
Username: createUserResult.User?.Username,
Username: attributeValue("sub", createUserResult.User?.Attributes),
UserStatus: createUserResult.User?.UserStatus,
});

Expand Down
3 changes: 2 additions & 1 deletion integration-tests/aws-sdk/adminGetUser.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ClockFake } from "../../src/__tests__/clockFake";
import { withCognitoSdk } from "./setup";
import { attributeValue } from "../../src/services/userPoolService";

const currentDate = new Date();
const roundedDate = new Date(currentDate.getTime());
Expand Down Expand Up @@ -36,7 +37,7 @@ describe(
UserAttributes: createUserResult.User?.Attributes,
UserCreateDate: createUserResult.User?.UserCreateDate,
UserLastModifiedDate: createUserResult.User?.UserLastModifiedDate,
Username: createUserResult.User?.Username,
Username: attributeValue("sub", createUserResult.User?.Attributes),
UserStatus: createUserResult.User?.UserStatus,
});
});
Expand Down
3 changes: 2 additions & 1 deletion integration-tests/aws-sdk/adminSetUserPassword.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ClockFake } from "../../src/__tests__/clockFake";
import { withCognitoSdk } from "./setup";
import { attributeValue } from "../../src/services/userPoolService";

const currentDate = new Date();
const roundedDate = new Date(currentDate.getTime());
Expand Down Expand Up @@ -45,7 +46,7 @@ describe(
UserAttributes: createUserResult.User?.Attributes,
UserCreateDate: createUserResult.User?.UserCreateDate,
UserLastModifiedDate: createUserResult.User?.UserLastModifiedDate,
Username: createUserResult.User?.Username,
Username: attributeValue("sub", createUserResult.User?.Attributes),
UserStatus: "CONFIRMED",
});
});
Expand Down
8 changes: 2 additions & 6 deletions src/targets/addCustomAttributes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@ import { newMockCognitoService } from "../__tests__/mockCognitoService";
import { newMockUserPoolService } from "../__tests__/mockUserPoolService";
import { TestContext } from "../__tests__/testContext";
import * as TDB from "../__tests__/testDataBuilder";
import {
GroupNotFoundError,
InvalidParameterError,
UserNotFoundError,
} from "../errors";
import { CognitoService, UserPoolService } from "../services";
import { InvalidParameterError } from "../errors";
import { CognitoService } from "../services";
import {
AddCustomAttributes,
AddCustomAttributesTarget,
Expand Down
3 changes: 2 additions & 1 deletion src/targets/adminGetUser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as TDB from "../__tests__/testDataBuilder";
import { UserNotFoundError } from "../errors";
import { UserPoolService } from "../services";
import { AdminGetUser, AdminGetUserTarget } from "./adminGetUser";
import { attributeValue } from "../services/userPoolService";

describe("AdminGetUser target", () => {
let adminGetUser: AdminGetUserTarget;
Expand Down Expand Up @@ -32,7 +33,7 @@ describe("AdminGetUser target", () => {
UserAttributes: existingUser.Attributes,
UserCreateDate: new Date(existingUser.UserCreateDate),
UserLastModifiedDate: new Date(existingUser.UserLastModifiedDate),
Username: existingUser.Username,
Username: attributeValue("sub", existingUser.Attributes),
UserStatus: existingUser.UserStatus,
});
});
Expand Down
3 changes: 2 additions & 1 deletion src/targets/adminGetUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
import { UserNotFoundError } from "../errors";
import { Services } from "../services";
import { Target } from "./Target";
import { attributeValue } from "../services/userPoolService";

export type AdminGetUserTarget = Target<
AdminGetUserRequest,
Expand All @@ -30,7 +31,7 @@ export const AdminGetUser =
UserCreateDate: user.UserCreateDate,
UserLastModifiedDate: user.UserLastModifiedDate,
UserMFASettingList: undefined,
Username: user.Username,
Username: attributeValue("sub", user.Attributes)!,
UserStatus: user.UserStatus,
};
};
4 changes: 2 additions & 2 deletions src/targets/getUser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe("GetUser target", () => {
auth_time: new Date(),
jti: uuid.v4(),
client_id: "test",
username: user.Username,
username: attributeValue("sub", user.Attributes),
},
PrivateKey.pem,
{
Expand All @@ -51,7 +51,7 @@ describe("GetUser target", () => {
expect(output).toBeDefined();
expect(output).toEqual({
UserAttributes: user.Attributes,
Username: user.Username,
Username: attributeValue("sub", user.Attributes),
});
});

Expand Down
3 changes: 2 additions & 1 deletion src/targets/getUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { InvalidParameterError, UserNotFoundError } from "../errors";
import { Services } from "../services";
import { Token } from "../services/tokenGenerator";
import { Target } from "./Target";
import { attributeValue } from "../services/userPoolService";

export type GetUserTarget = Target<GetUserRequest, GetUserResponse>;

Expand All @@ -33,6 +34,6 @@ export const GetUser =
PreferredMfaSetting: user.PreferredMfaSetting,
UserAttributes: user.Attributes,
UserMFASettingList: user.UserMFASettingList,
Username: user.Username,
Username: attributeValue("sub", user.Attributes)!,
};
};