Merge branch 'develop'

This commit is contained in:
SAITO-PC-3\saito.k 2024-04-17 14:02:05 +09:00
commit a7b18d8151
6 changed files with 98 additions and 16 deletions

View File

@ -49,7 +49,7 @@ export class Account {
@Column({ nullable: true, type: "datetime" })
deleted_at: Date | null;
@Column({ nullable: true, type: "datetime" })
@Column({ nullable: true, type: "varchar" })
created_by: string | null;
@CreateDateColumn({
@ -58,7 +58,7 @@ export class Account {
}) // defaultはSQLite用設定値.本番用は別途migrationで設定
created_at: Date;
@Column({ nullable: true, type: "datetime" })
@Column({ nullable: true, type: "varchar"})
updated_by: string | null;
@UpdateDateColumn({

View File

@ -40,7 +40,7 @@ export class License {
@Column({ nullable: true, type: "bigint", transformer: bigintTransformer })
delete_order_id: number | null;
@Column({ nullable: true, type: "datetime" })
@Column({ nullable: true, type: "varchar" })
created_by: string | null;
@CreateDateColumn({
@ -49,7 +49,7 @@ export class License {
})
created_at: Date;
@Column({ nullable: true, type: "datetime" })
@Column({ nullable: true, type: "varchar" })
updated_by: string | null;
@UpdateDateColumn({
@ -89,7 +89,7 @@ export class LicenseAllocationHistory {
@Column({ nullable: true, type: "datetime" })
deleted_at: Date | null;
@Column({ nullable: true, type: "datetime" })
@Column({ nullable: true, type: "varchar" })
created_by: string | null;
@CreateDateColumn({
@ -98,7 +98,7 @@ export class LicenseAllocationHistory {
})
created_at: Date;
@Column({ nullable: true, type: "datetime" })
@Column({ nullable: true, type: "varchar" })
updated_by: string | null;
@UpdateDateColumn({

View File

@ -31,6 +31,9 @@ export class User {
@Column({ nullable: true, type: "varchar" })
accepted_eula_version: string | null;
@Column({ nullable: true, type: "varchar" })
accepted_privacy_notice_version: string | null;
@Column({ nullable: true, type: "varchar" })
accepted_dpa_version: string | null;
@ -55,7 +58,7 @@ export class User {
@Column({ nullable: true, type: "datetime" })
deleted_at: Date | null;
@Column({ nullable: true, type: "datetime" })
@Column({ nullable: true, type: "varchar" })
created_by: string | null;
@CreateDateColumn({
@ -64,7 +67,7 @@ export class User {
}) // defaultはSQLite用設定値.本番用は別途migrationで設定
created_at: Date;
@Column({ nullable: true, type: "datetime" })
@Column({ nullable: true, type: "varchar" })
updated_by: string | null;
@UpdateDateColumn({

View File

@ -167,9 +167,17 @@ async function getAlertMailTargetAccount(
// 第五のアカウントを取得
const accountRepository = datasource.getRepository(Account);
// 管理者ユーザーが規約に同意しているアカウントのみを取得
// 第五階層が同意する規約はeulaとprivacy_noticeのみであるため、それらがnullでないことを条件に追加
// 管理者が規約同意していない = 一度もログインしていないアカウントであるため、そのアカウントにはアラートメールを送信しない
// プロダクト バックログ項目 4073: [保守]システムに一度もログインしていないユーザーにはライセンスアラートメールを送信しないようにしたい の対応
const accounts = await accountRepository.find({
where: {
tier: TIERS.TIER5,
primaryAdminUser: {
accepted_eula_version: Not(IsNull()),
accepted_privacy_notice_version: Not(IsNull()),
},
},
relations: {
primaryAdminUser: true,

View File

@ -96,7 +96,7 @@ export const makeTestAccount = async (
locked: d?.locked ?? false,
company_name: d?.company_name ?? "test inc.",
verified: d?.verified ?? true,
deleted_at: d?.deleted_at ?? "",
deleted_at: d?.deleted_at ?? null,
created_by: d?.created_by ?? "test_runner",
created_at: d?.created_at ?? new Date(),
updated_by: d?.updated_by ?? "updater",
@ -112,8 +112,16 @@ export const makeTestAccount = async (
account_id: accountId,
role: d?.role ?? "admin none",
author_id: d?.author_id ?? undefined,
accepted_eula_version: d?.accepted_eula_version ?? "1.0",
accepted_dpa_version: d?.accepted_dpa_version ?? "1.0",
accepted_eula_version:
d?.accepted_eula_version !== undefined
? d.accepted_eula_version
: "1.0",
accepted_privacy_notice_version:
d?.accepted_privacy_notice_version !== undefined
? d.accepted_privacy_notice_version
: "1.0",
accepted_dpa_version:
d?.accepted_dpa_version !== undefined ? d.accepted_dpa_version : "1.0",
email_verified: d?.email_verified ?? true,
auto_renew: d?.auto_renew ?? true,
notification: d?.notification ?? true,

View File

@ -54,7 +54,7 @@ describe("licenseAlert", () => {
const { account, admin } = await makeTestAccount(
source,
{ tier: 5 },
{ external_id: "external_id1" }
{ external_id: "external_id1", accepted_dpa_version: null }
);
await createLicense(
source,
@ -80,7 +80,7 @@ describe("licenseAlert", () => {
// redisからキャッシュが削除されていることを確認
const getAsync = promisify(redisClient.keys).bind(redisClient);
const keys = await getAsync(`*`);
expect(keys).toHaveLength(0);
expect(keys).toHaveLength(0);
});
it("ライセンス在庫不足メール、ライセンス失効警告メールが送信されること", async () => {
@ -97,7 +97,11 @@ describe("licenseAlert", () => {
const { account, admin } = await makeTestAccount(
source,
{ tier: 5 },
{ external_id: "external_id2", auto_renew: false }
{
external_id: "external_id2",
auto_renew: false,
accepted_dpa_version: null,
}
);
await createLicense(
source,
@ -141,7 +145,7 @@ describe("licenseAlert", () => {
const { account, admin } = await makeTestAccount(
source,
{ tier: 5 },
{ external_id: "external_id3" }
{ external_id: "external_id3", accepted_dpa_version: null }
);
await createLicense(
source,
@ -196,7 +200,11 @@ describe("licenseAlert", () => {
const { account, admin } = await makeTestAccount(
source,
{ tier: 5 },
{ external_id: "external_id4", auto_renew: true }
{
external_id: "external_id4",
auto_renew: true,
accepted_dpa_version: null,
}
);
await createLicense(
source,
@ -224,6 +232,50 @@ describe("licenseAlert", () => {
const keys = await getAsync(`*`);
expect(keys).toHaveLength(0);
});
it("規約同意していない管理者ユーザーに対して、ライセンス失効警告メール・在庫不足メールが送信されないこと", async () => {
if (!source) fail();
const context = new InvocationContext();
const sendgridMock = new SendGridServiceMock() as SendGridService;
const adb2cMock = new AdB2cServiceMock() as AdB2cService;
// 呼び出し回数でテスト成否を判定
const spySend = jest.spyOn(sendgridMock, "sendMail");
const currentDate = new DateWithZeroTime();
const expiringSoonDate = new DateWithDayEndTime(currentDate.getTime());
const { account, admin } = await makeTestAccount(
source,
{ tier: 5 },
{
external_id: "external_id5",
auto_renew: false,
accepted_eula_version: null,
accepted_privacy_notice_version: null,
}
);
await createLicense(
source,
1,
expiringSoonDate,
account.id,
"NORMAL",
"Allocated",
admin.id,
null,
null,
null
);
await licenseAlertProcessing(
context,
source,
redisClient,
sendgridMock,
adb2cMock
);
// メール送信がされていないことを確認
expect(spySend.mock.calls).toHaveLength(0);
});
});
// テスト用sendgrid
@ -305,6 +357,17 @@ export class AdB2cServiceMock {
},
],
},
{
id: "external_id5",
displayName: "test5",
identities: [
{
signInType: ADB2C_SIGN_IN_TYPE.EMAILADDRESS,
issuer: "issuer",
issuerAssignedId: "test5@mail.com",
},
],
},
];
return AdB2cMockUsers;
}