mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-18 05:09:08 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a794de2179 | ||
|
|
740540d4dc |
@@ -0,0 +1,59 @@
|
|||||||
|
let mockStrategyOptions: { scope: string };
|
||||||
|
|
||||||
|
jest.mock('passport-hubspot-oauth2', () => ({
|
||||||
|
Strategy: class {
|
||||||
|
constructor(options: { scope: string }) {
|
||||||
|
mockStrategyOptions = options;
|
||||||
|
}
|
||||||
|
|
||||||
|
authenticate() {}
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
jest.mock('@nestjs/passport', () => ({
|
||||||
|
PassportStrategy: (Strategy) => Strategy,
|
||||||
|
}));
|
||||||
|
|
||||||
|
import { HubspotStrategy } from './hubspot-strategy';
|
||||||
|
import type { OauthSecrets } from 'src/utils/OauthSecrets';
|
||||||
|
import type { OauthService } from '../oauth.service';
|
||||||
|
|
||||||
|
describe('HubspotStrategy', () => {
|
||||||
|
it('requests the content scope without requesting Marketing write scopes', () => {
|
||||||
|
const oauthSecrets = {
|
||||||
|
hubspot: {
|
||||||
|
client_id: '',
|
||||||
|
client_secret: '',
|
||||||
|
redirect_uri: '',
|
||||||
|
},
|
||||||
|
} as OauthSecrets;
|
||||||
|
|
||||||
|
new HubspotStrategy(oauthSecrets, {} as OauthService);
|
||||||
|
|
||||||
|
const scopes = mockStrategyOptions.scope.split(' ');
|
||||||
|
|
||||||
|
expect(scopes).toEqual([
|
||||||
|
'tickets',
|
||||||
|
'automation',
|
||||||
|
'business-intelligence',
|
||||||
|
'oauth',
|
||||||
|
'forms',
|
||||||
|
'content',
|
||||||
|
'integration-sync',
|
||||||
|
'sales-email-read',
|
||||||
|
'crm.lists.read',
|
||||||
|
'crm.objects.contacts.read',
|
||||||
|
'crm.schemas.contacts.read',
|
||||||
|
'crm.objects.companies.read',
|
||||||
|
'crm.objects.deals.read',
|
||||||
|
'crm.schemas.companies.read',
|
||||||
|
'crm.schemas.deals.read',
|
||||||
|
'crm.objects.owners.read',
|
||||||
|
'crm.objects.quotes.read',
|
||||||
|
'crm.schemas.quotes.read',
|
||||||
|
'crm.objects.line_items.read',
|
||||||
|
'crm.schemas.line_items.read',
|
||||||
|
]);
|
||||||
|
expect(scopes).not.toContain('marketing.email.write');
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -17,7 +17,7 @@ export class HubspotStrategy extends PassportStrategy(Strategy) {
|
|||||||
clientSecret: oauthSecrets.hubspot.client_secret,
|
clientSecret: oauthSecrets.hubspot.client_secret,
|
||||||
callbackURL: oauthSecrets.hubspot.redirect_uri,
|
callbackURL: oauthSecrets.hubspot.redirect_uri,
|
||||||
scope:
|
scope:
|
||||||
'tickets automation business-intelligence oauth forms integration-sync sales-email-read crm.lists.read crm.objects.contacts.read crm.schemas.contacts.read crm.objects.companies.read crm.objects.deals.read crm.schemas.companies.read crm.schemas.deals.read crm.objects.owners.read crm.objects.quotes.read crm.schemas.quotes.read crm.objects.line_items.read crm.schemas.line_items.read',
|
'tickets automation business-intelligence oauth forms content integration-sync sales-email-read crm.lists.read crm.objects.contacts.read crm.schemas.contacts.read crm.objects.companies.read crm.objects.deals.read crm.schemas.companies.read crm.schemas.deals.read crm.objects.owners.read crm.objects.quotes.read crm.schemas.quotes.read crm.objects.line_items.read crm.schemas.line_items.read',
|
||||||
passReqToCallback: true,
|
passReqToCallback: true,
|
||||||
},
|
},
|
||||||
(accessToken, refreshToken, tokenInfo, profile, done) => {
|
(accessToken, refreshToken, tokenInfo, profile, done) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user