Skip to content

Commit

Permalink
Updated testcases & bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
izahirclemencia committed Aug 18, 2023
1 parent 7ce2647 commit 7a846b3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ describe('ParLoginService', () => {
});

expect(result).toBeUndefined();
expect(spy).toHaveBeenCalledOnceWith(config, { some: 'thing' });
expect(spy).toHaveBeenCalledOnceWith(config, {
customParams: { some: 'thing' },
});
}));

it('returns undefined and logs error when no url could be created', waitForAsync(() => {
Expand Down Expand Up @@ -184,6 +186,8 @@ describe('ParLoginService', () => {
responseType: 'stubValue',
};

const authOptions = {};

spyOn(
authWellKnownService,
'queryAndStoreAuthWellKnownEndPoints'
Expand All @@ -195,7 +199,7 @@ describe('ParLoginService', () => {
spyOn(urlService, 'getAuthorizeParUrl').and.returnValue('some-par-url');
const spy = spyOn(redirectService, 'redirectTo');

service.loginPar(config);
service.loginPar(config, authOptions);

expect(spy).toHaveBeenCalledOnceWith('some-par-url');
}));
Expand Down Expand Up @@ -306,7 +310,9 @@ describe('ParLoginService', () => {
})
.subscribe({
error: (err) => {
expect(spy).toHaveBeenCalledOnceWith(config, { some: 'thing' });
expect(spy).toHaveBeenCalledOnceWith(config, {
customParams: { some: 'thing' },
});
expect(err.message).toBe(
"Could not create URL with param requestUri: 'url'"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class ParService {

postParRequest(
configuration: OpenIdConfiguration,
authOptions: AuthOptions
authOptions?: AuthOptions
): Observable<ParResponse> {
let headers: HttpHeaders = new HttpHeaders();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1348,7 +1348,9 @@ describe('UrlService Tests', () => {
);

const resultObs$ = service.createBodyForParCodeFlowRequest(config, {
any: 'otherThing',
customParams: {
any: 'otherThing',
},
});

resultObs$.subscribe((result) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@ export class UrlService {

createBodyForParCodeFlowRequest(
configuration: OpenIdConfiguration,
authOptions?: AuthOptions): Observable<string> {
authOptions?: AuthOptions
): Observable<string> {
const redirectUrl = this.getRedirectUrl(configuration, authOptions);

if (!redirectUrl) {
Expand Down Expand Up @@ -351,8 +352,11 @@ export class UrlService {
);
}

if (authOptions.customParams) {
params = this.appendCustomParams({ ...authOptions.customParams }, params);
if (authOptions?.customParams) {
params = this.appendCustomParams(
{ ...authOptions.customParams },
params
);
}

return params.toString();
Expand Down

0 comments on commit 7a846b3

Please sign in to comment.