mirror of
https://github.com/logto-io/logto.git
synced 2025-02-17 22:04:19 -05:00
chore: add IT for switching passwordless connector (#2591)
This commit is contained in:
parent
57234cee66
commit
dd2a33f921
5 changed files with 75 additions and 4 deletions
2
.github/workflows/integration-test.yml
vendored
2
.github/workflows/integration-test.yml
vendored
|
@ -84,7 +84,7 @@ jobs:
|
|||
- name: Add mock connectors
|
||||
working-directory: tests
|
||||
run: |
|
||||
npm run cli connector add @logto/connector-mock-sms @logto/connector-mock-email @logto/connector-mock-social -- -p ../logto
|
||||
npm run cli connector add @logto/connector-mock-sms @logto/connector-mock-email @logto/connector-mock-standard-email @logto/connector-mock-social -- -p ../logto
|
||||
|
||||
- name: Run Logto
|
||||
working-directory: logto/
|
||||
|
|
|
@ -140,6 +140,45 @@ export const mockEmailConnectorConfig = {
|
|||
],
|
||||
};
|
||||
|
||||
export const mockStandardEmailConnectorId = 'mock-standard-email-service';
|
||||
export const mockStandardEmailConnectorConfig = {
|
||||
apiKey: 'api-key-value',
|
||||
fromEmail: 'noreply@logto.test.io',
|
||||
fromName: 'from-name-value',
|
||||
templates: [
|
||||
{
|
||||
usageType: 'SignIn',
|
||||
type: 'text/plain',
|
||||
subject: 'Logto SignIn Template',
|
||||
content: 'This is for sign-in purposes only. Your passcode is {{code}}.',
|
||||
},
|
||||
{
|
||||
usageType: 'Register',
|
||||
type: 'text/plain',
|
||||
subject: 'Logto Register Template',
|
||||
content: 'This is for registering purposes only. Your passcode is {{code}}.',
|
||||
},
|
||||
{
|
||||
usageType: 'ForgotPassword',
|
||||
type: 'text/plain',
|
||||
subject: 'Logto Forgot Password Template',
|
||||
content: 'This is for forgot-password purposes only. Your passcode is {{code}}.',
|
||||
},
|
||||
{
|
||||
usageType: 'Continue',
|
||||
type: 'text/plain',
|
||||
subject: 'Logto Continue Template',
|
||||
content: 'This is for completing user profile purposes only. Your passcode is {{code}}.',
|
||||
},
|
||||
{
|
||||
usageType: 'Test',
|
||||
type: 'text/plain',
|
||||
subject: 'Logto Test Template',
|
||||
content: 'This is for testing purposes only. Your passcode is {{code}}.',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const mockSocialConnectorId = 'mock-social-connector';
|
||||
export const mockSocialConnectorTarget = 'mock-social';
|
||||
export const mockSocialConnectorConfig = {
|
||||
|
|
|
@ -14,6 +14,7 @@ import {
|
|||
deleteUserIdentity,
|
||||
postConnector,
|
||||
updateConnectorConfig,
|
||||
deleteConnectorById,
|
||||
} from '@/api';
|
||||
import { createUserByAdmin, bindSocialToNewCreatedUser } from '@/helpers';
|
||||
|
||||
|
@ -81,5 +82,7 @@ describe('admin console user management', () => {
|
|||
const updatedUser = await getUser(createdUserId);
|
||||
|
||||
expect(updatedUser.identities).not.toHaveProperty(mockSocialConnectorTarget);
|
||||
|
||||
await deleteConnectorById(id);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -7,6 +7,8 @@ import {
|
|||
mockSmsConnectorId,
|
||||
mockSocialConnectorConfig,
|
||||
mockSocialConnectorId,
|
||||
mockStandardEmailConnectorConfig,
|
||||
mockStandardEmailConnectorId,
|
||||
} from '@/__mocks__/connectors-mock';
|
||||
import {
|
||||
deleteConnectorById,
|
||||
|
@ -69,15 +71,29 @@ test('connector set-up flow', async () => {
|
|||
/*
|
||||
* Change to another SMS/Email connector
|
||||
*/
|
||||
// FIXME @Darcy [LOG-4750,4751]: complete this IT after add another mock sms/email connector (or other current existing connector could be affected)
|
||||
const { id } = await postConnector(mockStandardEmailConnectorId);
|
||||
await updateConnectorConfig(id, mockStandardEmailConnectorConfig);
|
||||
connectorIdMap.set(mockStandardEmailConnectorId, id);
|
||||
const currentConnectors = await listConnectors();
|
||||
expect(
|
||||
currentConnectors.some((connector) => connector.connectorId === mockEmailConnectorId)
|
||||
).toBeFalsy();
|
||||
expect(
|
||||
currentConnectors.some((connector) => connector.connectorId === mockStandardEmailConnectorId)
|
||||
).toBeTruthy();
|
||||
expect(
|
||||
currentConnectors.find((connector) => connector.connectorId === mockStandardEmailConnectorId)
|
||||
?.config
|
||||
).toEqual(mockStandardEmailConnectorConfig);
|
||||
connectorIdMap.delete(mockEmailConnectorId);
|
||||
|
||||
/*
|
||||
* Delete (i.e. disable) a connector
|
||||
*/
|
||||
await expect(
|
||||
deleteConnectorById(connectorIdMap.get(mockEmailConnectorId))
|
||||
deleteConnectorById(connectorIdMap.get(mockStandardEmailConnectorId))
|
||||
).resolves.not.toThrow();
|
||||
connectorIdMap.delete(mockEmailConnectorId);
|
||||
connectorIdMap.delete(mockStandardEmailConnectorId);
|
||||
|
||||
/**
|
||||
* List connectors after manually setting up connectors.
|
||||
|
@ -130,4 +146,9 @@ test('send SMS/email test message', async () => {
|
|||
).resolves.not.toThrow();
|
||||
await expect(sendSmsTestMessage(mockSmsConnectorId, phone, {})).rejects.toThrow(HTTPError);
|
||||
await expect(sendEmailTestMessage(mockEmailConnectorId, email, {})).rejects.toThrow(HTTPError);
|
||||
|
||||
for (const [_connectorId, id] of connectorIdMap.entries()) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await deleteConnectorById(id);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -15,6 +15,7 @@ import {
|
|||
getUser,
|
||||
postConnector,
|
||||
updateConnectorConfig,
|
||||
deleteConnectorById,
|
||||
} from '@/api';
|
||||
import MockClient from '@/client';
|
||||
import { signUpIdentifiers } from '@/constants';
|
||||
|
@ -112,6 +113,13 @@ describe('social bind account', () => {
|
|||
await createUserByAdmin(username, password);
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
for (const [_connectorId, id] of connectorIdMap.entries()) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await deleteConnectorById(id);
|
||||
}
|
||||
});
|
||||
|
||||
it('bind new social account', async () => {
|
||||
const client = new MockClient();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue