-
Notifications
You must be signed in to change notification settings - Fork 14k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Microsoft Outlook service root endpoint
This change makes the service root configurable for the Microsoft Outlook nodes. The service root endpoint is configurable in the Outlook credential. The motivation behind this change is to allow the Microsoft Outlook N8N node to connect to the other tenant types such as the Microsoft GovCloud instances.
- Loading branch information
1 parent
073b05b
commit 1bb8e1b
Showing
3 changed files
with
109 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
packages/nodes-base/nodes/Microsoft/Outlook/test/v2/transport/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import type { ICredentialDataDecryptedObject, IExecuteFunctions } from 'n8n-workflow'; | ||
|
||
import * as transport from '../../../v2/transport'; | ||
|
||
const fakeExecute = (credentials: ICredentialDataDecryptedObject, result: unknown) => { | ||
const fakeExecuteFunction = { | ||
async getCredentials(): Promise<ICredentialDataDecryptedObject> { | ||
return credentials; | ||
}, | ||
|
||
helpers: { | ||
requestWithAuthentication: jest.fn().mockResolvedValue(result), | ||
}, | ||
} as unknown as IExecuteFunctions; | ||
return fakeExecuteFunction; | ||
}; | ||
|
||
describe('Test MicrosoftOutlookV2, transport => microsoftApiRequest', () => { | ||
it('should call microsoftApiRequest using the defined service root', async () => { | ||
const execute = fakeExecute( | ||
{ | ||
graphEndpoint: 'https://foo.bar', | ||
useShared: false, | ||
userPrincipalName: 'test-principal', | ||
}, | ||
'foo', | ||
); | ||
|
||
const result: string = (await transport.microsoftApiRequest.call( | ||
execute, | ||
'GET', | ||
'/foo', | ||
)) as string; | ||
|
||
expect(result).toEqual('foo'); | ||
expect(execute.helpers.requestWithAuthentication).toHaveBeenCalledTimes(1); | ||
expect(execute.helpers.requestWithAuthentication).toHaveBeenCalledWith( | ||
'microsoftOutlookOAuth2Api', | ||
{ | ||
headers: { 'Content-Type': 'application/json' }, | ||
method: 'GET', | ||
qs: {}, | ||
uri: 'https://foo.bar/v1.0/me/foo', | ||
json: true, | ||
}, | ||
); | ||
}); | ||
|
||
it('should call microsoftApiRequest using the service root if no root is provided', async () => { | ||
const execute = fakeExecute( | ||
{ | ||
useShared: false, | ||
userPrincipalName: 'test-principal', | ||
}, | ||
'foo', | ||
); | ||
|
||
const result: string = (await transport.microsoftApiRequest.call( | ||
execute, | ||
'GET', | ||
'/foo', | ||
)) as string; | ||
|
||
expect(result).toEqual('foo'); | ||
expect(execute.helpers.requestWithAuthentication).toHaveBeenCalledTimes(1); | ||
expect(execute.helpers.requestWithAuthentication).toHaveBeenCalledWith( | ||
'microsoftOutlookOAuth2Api', | ||
{ | ||
headers: { 'Content-Type': 'application/json' }, | ||
method: 'GET', | ||
qs: {}, | ||
uri: 'https://graph.microsoft.com/v1.0/me/foo', | ||
json: true, | ||
}, | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters