Skip to content

Commit

Permalink
discover service test case implemented #44
Browse files Browse the repository at this point in the history
  • Loading branch information
RumiAust authored and raghunandanarava committed Jun 7, 2022
1 parent 403d7b6 commit 27844a3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/discovery/discovery.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,18 @@ describe('DiscoveryService', () => {
it('should be defined', () => {
expect(service).toBeDefined();
});

describe('get_issuer', () => {
it('should fail if no issuer is provided', async () => {
await expect(service.get_issuer(undefined)).rejects.toThrow(
'There was no issuer string passed to get the issuer',
);
});

it('should fail is an empty issuer is provided', async () => {
await expect(service.get_issuer('')).rejects.toThrow(
'There was no issuer string passed to get the issuer',
);
});
});
});
8 changes: 7 additions & 1 deletion src/discovery/discovery.service.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import { Injectable } from '@nestjs/common';
import {HttpException, HttpStatus, Injectable} from '@nestjs/common';
import {Issuer} from "openid-client";

@Injectable()
export class DiscoveryService {

async get_issuer(issuer_s) {
if(issuer_s === undefined || issuer_s === ''){
throw new HttpException(
'There was no issuer string passed to get the issuer',
HttpStatus.BAD_REQUEST,
);
}
const issuer = await Issuer.discover(issuer_s);
return issuer;
}
Expand Down

0 comments on commit 27844a3

Please sign in to comment.