Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework GitHub acceptor and move to its own module #2021

Merged
merged 14 commits into from
Nov 9, 2018
Prev Previous commit
Next Next commit
Tests should pass when server secrets are undefined
  • Loading branch information
paulmelnikow committed Oct 27, 2018
commit b0e37f8a813b4cef385de23eebdae9b9b3841377
19 changes: 9 additions & 10 deletions services/github/auth/acceptor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const { expect } = require('chai')
const Camp = require('camp')
const got = require('got')
const queryString = require('query-string')
const sinon = require('sinon')
const nock = require('nock')
const config = require('../../../lib/test-config')
const serverSecrets = require('../../../lib/server-secrets')
Expand All @@ -14,23 +13,23 @@ const baseUri = `http://127.0.0.1:${config.port}`
const fakeClientId = 'githubdabomb'

describe('Github token acceptor', function() {
let sandbox
beforeEach(function() {
sandbox = sinon.createSandbox()
sandbox.stub(serverSecrets, 'gh_client_id').value(fakeClientId)
sandbox.stub(serverSecrets, 'shieldsIps').value([])
// Frustratingly, potentially undefined properties can't reliably be stubbed
// with Sinon.
// https://github.com/sinonjs/sinon/pull/1557
before(function() {
serverSecrets.gh_client_id = fakeClientId
serverSecrets.shieldsIps = []
})

afterEach(function() {
sandbox.restore()
after(function() {
delete serverSecrets.gh_client_id
delete serverSecrets.shieldsIps
})

let camp
beforeEach(function(done) {
camp = Camp.start({ port: config.port, hostname: '::' })
camp.on('listening', () => done())
})

afterEach(function(done) {
if (camp) {
camp.close(() => done())
Expand Down