diff --git a/runtime/auth-http.spec.ts b/runtime/auth-http.spec.ts index 4a87005a..19951b7c 100644 --- a/runtime/auth-http.spec.ts +++ b/runtime/auth-http.spec.ts @@ -203,4 +203,25 @@ describe('SkyAuthHttp', () => { }); }); + it('should include the envId regardless of permission scope', () => { + const search = '?envid=1234'; + const getTokenSpy = spyOn(BBAuth, 'getToken'); + + setupInjector(search); + skyAuthHttp.get('example.com'); + + expect(getTokenSpy).toHaveBeenCalledWith({ + envId: '1234' + }); + }); + + it('should not include the envId if undefined', () => { + const getTokenSpy = spyOn(BBAuth, 'getToken'); + + setupInjector(''); + skyAuthHttp.get('example.com'); + + expect(getTokenSpy).toHaveBeenCalledWith({}); + }); + }); diff --git a/runtime/auth-http.ts b/runtime/auth-http.ts index 1b6385f6..d45c85ae 100644 --- a/runtime/auth-http.ts +++ b/runtime/auth-http.ts @@ -79,15 +79,19 @@ export class SkyAuthHttp extends Http { options?: RequestOptionsArgs ): Observable { const tokenArgs: BBAuthGetTokenArgs = {}; - const leId: string = this.getLeId(); + const leId = this.getLeId(); + const envId = this.getEnvId(); - // See if this call was chained to withScope(), and if so, provide it when - // retrieving a token. + // See if this call was chained to withScope(), and if so, + // provide it when retrieving a token. if (this.permissionScope) { - tokenArgs.envId = this.getEnvId(); tokenArgs.permissionScope = this.permissionScope; } + if (envId) { + tokenArgs.envId = envId; + } + if (leId) { tokenArgs.leId = leId; }