mirror of
https://github.com/logto-io/logto.git
synced 2025-01-06 20:40:08 -05:00
chore: response of connector POST API should be ConnectorResponse (#2699)
This commit is contained in:
parent
f50509dfab
commit
87ebd057ea
2 changed files with 12 additions and 14 deletions
|
@ -40,6 +40,7 @@ const {
|
|||
countConnectorByConnectorId,
|
||||
deleteConnectorById,
|
||||
deleteConnectorByIds,
|
||||
insertConnector,
|
||||
} = await mockEsmWithActual('#src/queries/connector.js', () => ({
|
||||
findConnectorById: jest.fn(),
|
||||
countConnectorByConnectorId: jest.fn(),
|
||||
|
@ -165,20 +166,16 @@ describe('connector route', () => {
|
|||
...mockLogtoConnector,
|
||||
},
|
||||
]);
|
||||
const response = await connectorRequest.post('/connectors').send({
|
||||
await connectorRequest.post('/connectors').send({
|
||||
connectorId: 'connectorId',
|
||||
config: { cliend_id: 'client_id', client_secret: 'client_secret' },
|
||||
});
|
||||
expect(response.body).toMatchObject(
|
||||
expect(insertConnector).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
connectorId: 'connectorId',
|
||||
config: {
|
||||
cliend_id: 'client_id',
|
||||
client_secret: 'client_secret',
|
||||
},
|
||||
config: { cliend_id: 'client_id', client_secret: 'client_secret' },
|
||||
})
|
||||
);
|
||||
expect(response).toHaveProperty('statusCode', 200);
|
||||
});
|
||||
|
||||
it('throws when connector factory not found', async () => {
|
||||
|
@ -216,12 +213,12 @@ describe('connector route', () => {
|
|||
...mockLogtoConnector,
|
||||
},
|
||||
]);
|
||||
const response = await connectorRequest.post('/connectors').send({
|
||||
await connectorRequest.post('/connectors').send({
|
||||
connectorId: 'id0',
|
||||
config: { cliend_id: 'client_id', client_secret: 'client_secret' },
|
||||
metadata: { target: 'new_target' },
|
||||
});
|
||||
expect(response.body).toMatchObject(
|
||||
expect(insertConnector).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
connectorId: 'id0',
|
||||
config: {
|
||||
|
@ -231,7 +228,6 @@ describe('connector route', () => {
|
|||
metadata: { target: 'new_target' },
|
||||
})
|
||||
);
|
||||
expect(response).toHaveProperty('statusCode', 200);
|
||||
});
|
||||
|
||||
it('throws when add more than 1 instance with non-connector factory', async () => {
|
||||
|
@ -266,12 +262,11 @@ describe('connector route', () => {
|
|||
},
|
||||
]);
|
||||
countConnectorByConnectorId.mockResolvedValueOnce({ count: 0 });
|
||||
const response = await connectorRequest.post('/connectors').send({
|
||||
await connectorRequest.post('/connectors').send({
|
||||
connectorId: 'id1',
|
||||
config: { cliend_id: 'client_id', client_secret: 'client_secret' },
|
||||
});
|
||||
expect(response).toHaveProperty('statusCode', 200);
|
||||
expect(response.body).toMatchObject(
|
||||
expect(insertConnector).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
connectorId: 'id1',
|
||||
config: {
|
||||
|
|
|
@ -159,7 +159,7 @@ export default function connectorRoutes<T extends AuthedRouter>(router: T) {
|
|||
}
|
||||
|
||||
const insertConnectorId = generateConnectorId();
|
||||
ctx.body = await insertConnector({
|
||||
await insertConnector({
|
||||
id: insertConnectorId,
|
||||
connectorId,
|
||||
...cleanDeep({ syncProfile, config, metadata }),
|
||||
|
@ -186,6 +186,9 @@ export default function connectorRoutes<T extends AuthedRouter>(router: T) {
|
|||
}
|
||||
}
|
||||
|
||||
const connector = await getLogtoConnectorById(insertConnectorId);
|
||||
ctx.body = transpileLogtoConnector(connector);
|
||||
|
||||
return next();
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue