Skip to content

Commit

Permalink
Merge pull request #52 from renderforest/stage
Browse files Browse the repository at this point in the history
release 1.4.8
  • Loading branch information
emarukyan authored Jan 27, 2018
2 parents f567d86 + c5046aa commit 7a46831
Show file tree
Hide file tree
Showing 7 changed files with 192 additions and 133 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,4 @@ typings/

#IDE
.idea/
.vscode/
13 changes: 0 additions & 13 deletions .vscode/settings.json

This file was deleted.

6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ Auth service to set authorization and authorize request.
[![GitHub release](https://img.shields.io/github/release/renderforest/service-auth.svg)](https://github.com/renderforest/service-auth/releases)
[![GitHub stars](https://img.shields.io/github/stars/renderforest/service-auth.svg)](https://github.com/renderforest/service-auth/stargazers)

[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/dwyl/esta/issues)
[![HitCount](http://hits.dwyl.com/renderforest/service-auth.svg)](http://hits.dwyl.com/renderforest/service-auth)
[![Maintained](https://img.shields.io/badge/maintained-%E2%9C%94-brightgreen.svg)](https://github.com/renderforest/service-auth)
[![Known Vulnerabilities](https://snyk.io/test/github/renderforest/service-auth/badge.svg)](https://snyk.io/test/github/renderforest/service-auth)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)

[![Dep](https://img.shields.io/david/renderforest/service-auth.svg)](https://david-dm.org/renderforest/service-auth)
[![DevDep](https://img.shields.io/david/dev/renderforest/service-auth.svg)](https://david-dm.org/renderforest/service-auth?type=dev)

Expand Down
20 changes: 20 additions & 0 deletions __tests__/lib/authorize.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,26 @@ describe('Test authorize middleware: ', () => {
})
})

test('should return `Invalid authorization key`. In case of `originalUrl` is missing in `req` object.', () => {
const req = {
headers: {
authorization: 'mock-auth',
clientid: 'mock-clientid',
nonce: 'mock-nonce',
timestamp: 'mock-timestamp'
},
__signKey: 'mock-signKey',
url: 'mock-url',
body: 'mock-body'
}

authorize.authorize(req, undefined, (result) => {
expect(result).toBeInstanceOf(Error)
expect(result.name).toEqual('ServiceAuthError')
expect(result.message).toEqual('Invalid authorization key.')
})
})

test('should be undefined. In case of `authHash` is equal to hash.', () => {
const url = 'https://mock.com'
const clientId = 'mock-clientid'
Expand Down
15 changes: 15 additions & 0 deletions __tests__/lib/set-authorization.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,21 @@ describe('set authorization: ', () => {
expect(setAuth.headers.authorization).toBeDefined()
})

test('should be valid. In case of `path` is fallsy.', () => {
const options = {
uri: 'https://'
}
const signKey = 'mock-signKey'
const clientId = 'mock-clientid'
const setAuth = setAuthorization.setAuthorization(options, signKey, clientId)

expect(typeof setAuth).toBe('object')
expect(setAuth.headers.nonce).toBeDefined()
expect(setAuth.headers.clientid).toBe(clientId)
expect(setAuth.headers.timestamp).toBeDefined()
expect(setAuth.headers.authorization).toBeDefined()
})

test('should be valid. In case of presence of query in `uri`.', () => {
const options = {
uri: 'https://mock-mock.com?mock=mock-value',
Expand Down
Loading

0 comments on commit 7a46831

Please sign in to comment.