Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

RC > Always provide envId regardless of permission scope #427

Merged
merged 4 commits into from
Jul 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions runtime/auth-http.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({});
});

});
12 changes: 8 additions & 4 deletions runtime/auth-http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,19 @@ export class SkyAuthHttp extends Http {
options?: RequestOptionsArgs
): Observable<Response> {
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;
}
Expand Down