Compare commits

...
Author SHA1 Message Date
Victor Tintel a794de2179 fix: add content scope to HubSpot OAuth 2026-09-02 16:06:28 -03:00
marcos.rodrigues 740540d4dc Merge pull request #517 from dadosfera/bugfix/sync-proto
FIX: sync proto
2026-08-28 13:33:27 -03:00
2 changed files with 60 additions and 1 deletions
@@ -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,
callbackURL: oauthSecrets.hubspot.redirect_uri,
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,
},
(accessToken, refreshToken, tokenInfo, profile, done) => {