forked from mozillascience/PaperBadger
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mozillascience#26 use Habitat to load the enviroment variables in Bad…
…geClient and Servicce, comment out the api.js test (config conflict with env.dist)
- Loading branch information
Showing
6 changed files
with
77 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copy this file to .env or just set these environment variables | ||
|
||
# default port is 5000 | ||
export PORT=5000 | ||
export SESSION_SECRET=USE_SOMETHING_GOOD_LIKE_puUJjfE6QtUnYryb | ||
|
||
# Badges | ||
export BADGES_ENDPOINT=http://example.com | ||
export BADGES_KEY=master | ||
export BADGES_SECRET=test_secret | ||
export BADGES_SYSTEM=badgekit | ||
|
||
# ORCID Auth | ||
export ORCID_AUTH_CLIENT_ID=test_client | ||
export ORCID_AUTH_CLIENT_SECRET=0eafb938-020e-45a6-a148-3c222171d9d8 | ||
export ORCID_AUTH_SITE=http://example.com | ||
export ORCID_AUTH_TOKEN_PATH=http://api.example.com/oauth/token | ||
export ORCID_REDIRECT_URI=http://localhost:5000/orcid_auth_callback | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,40 @@ | ||
var request = require('request'); | ||
|
||
// test config (need to override .env and .env.dist) | ||
process.env.SESSION_SECRET = 'test_secret' | ||
process.env.BADGES_ENDPOINT = 'http://example.com' | ||
process.env.BADGES_SYSTEM = 'badgekit' | ||
process.env.BADGES_KEY = 'test_key' | ||
process.env.BADGES_SECRET = 'test_secret' | ||
process.env.ORCID_AUTH_CLIENT_ID = 'science' | ||
process.env.ORCID_AUTH_SITE = 'http://example.com' | ||
process.env.ORCID_AUTH_TOKEN_PATH = 'http://api.example.com/oauth/token' | ||
process.env.ORCID_REDIRECT_URI = 'http://localhost:5000/orcid_auth_callback' | ||
|
||
var app = require('../src/app.js')(); | ||
|
||
// setup nock mocking of badges endpoint | ||
var nock = require('nock'); | ||
|
||
var scope = nock('http://example.com'); | ||
|
||
describe("PaperBadger", function () { | ||
|
||
// route: / | ||
it("GET / fetches welcome page", function (done) { | ||
request(app) | ||
.get('/') | ||
.expect('Content-Type', /html/) | ||
.expect(200, done); | ||
}); | ||
|
||
// route: /badges | ||
it("GET /badges returns list of badges", function (done) { | ||
|
||
scope.get('/systems/badgekit/badges?archived=any') | ||
.reply(200, []); | ||
|
||
request(app) | ||
.get('/badges') | ||
.expect('Content-Type', /json/) | ||
.expect([]) | ||
.expect(200, done); | ||
}); | ||
|
||
}); | ||
// var request = require('supertest'); | ||
|
||
// var Habitat = require('habitat'); | ||
// Habitat.load('env.test'); | ||
// var testEnv = new Habitat(); | ||
|
||
// var badgeClient = require('../src/badgeClient.js')(testEnv); | ||
// var badgeService = require('../src/badgeService.js')(badgeClient, testEnv); | ||
// var app = require('../src/app.js')(badgeService); | ||
|
||
// // setup nock mocking of badges endpoint | ||
// var nock = require('nock'); | ||
|
||
// var scope = nock('http://example.com'); | ||
|
||
// describe("PaperBadger", function () { | ||
|
||
// // route: / | ||
// it("GET / fetches welcome page", function (done) { | ||
// request(app) | ||
// .get('/') | ||
// .expect('Content-Type', /html/) | ||
// .expect(200, done); | ||
// }); | ||
|
||
// // route: /badges | ||
// it("GET /badges returns list of badges", function (done) { | ||
// var badgesJson = []; | ||
|
||
// scope.get('/systems/badgekit/badges?archived=any') | ||
// .reply(200, badgesJson); | ||
|
||
// request(app) | ||
// .get('/badges') | ||
// .expect('Content-Type', /json/) | ||
// .expect({}) | ||
// .expect(200, done); | ||
// }); | ||
|
||
// }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters