Skip to content

Commit

Permalink
Make the baseUrl parameter required for refreshToken()
Browse files Browse the repository at this point in the history
Resolves: #96
Change-type: major
Signed-off-by: Thodoris Greasidis <[email protected]>
  • Loading branch information
thgreasi committed Mar 12, 2021
1 parent 66cc43e commit 12fd8c0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,9 @@ export function getRequest({
if (auth == null) {
throw new Error('Auth module not provided in initializer');
}
if (!baseUrl) {
throw new Error('The baseUrl parameter is required');
}

let response: BalenaRequestResponse<string>;
try {
Expand Down
6 changes: 6 additions & 0 deletions tests/token.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ describe 'Request (token):', ->
auth.setKey(johnDoeFixture.token)
mockServer.get('/user/v1/refresh-token').thenReply(200, janeDoeFixture.token)

it 'should error when the baseUrl is not provided', ->
auth.getKey().then (savedToken) ->
m.chai.expect(savedToken).to.equal(johnDoeFixture.token)
promise = request.refreshToken({})
m.chai.expect(promise).to.be.rejectedWith('The baseUrl parameter is required')

it 'should refresh the token', ->
auth.getKey().then (savedToken) ->
m.chai.expect(savedToken).to.equal(johnDoeFixture.token)
Expand Down

0 comments on commit 12fd8c0

Please sign in to comment.