Skip to content

Commit df54a75

Browse files
Add db configs to speed up integration tests
1 parent dea5733 commit df54a75

15 files changed

+1281
-19
lines changed

lib/models/oidc-manager.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict'
22

33
const url = require('url')
4+
const path = require('path')
45
const debug = require('./../debug').authentication
56

67
const OidcManager = require('oidc-auth-manager')
@@ -34,7 +35,7 @@ function fromServerConfig (argv) {
3435
let options = {
3536
debug,
3637
providerUri,
37-
dbPath: argv.dbPath || './db/oidc',
38+
dbPath: path.join(argv.dbPath, 'oidc') || './db/oidc',
3839
authCallbackUri,
3940
postLogoutUri,
4041
saltRounds: argv.saltRounds,

test/integration/account-creation-oidc.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ const path = require('path')
88
const fs = require('fs-extra')
99

1010
describe('AccountManager (OIDC account creation tests)', function () {
11-
this.timeout(10000)
1211
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'
1312

1413
var serverUri = 'https://localhost:3457'
1514
var host = 'localhost:3457'
1615
var ldpHttpsServer
17-
let dbPath = path.join(__dirname, '../resources/.db')
16+
let dbPath = path.join(__dirname, '../resources/accounts/db')
1817

1918
var ldp = ldnode.createServer({
2019
root: path.join(__dirname, '../resources/accounts/'),
@@ -34,7 +33,7 @@ describe('AccountManager (OIDC account creation tests)', function () {
3433

3534
after(function () {
3635
if (ldpHttpsServer) ldpHttpsServer.close()
37-
fs.removeSync(dbPath)
36+
fs.removeSync(path.join(dbPath, 'oidc/users/users'))
3837
})
3938

4039
var server = supertest(serverUri)

test/integration/authentication-oidc.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ describe('Authentication API (OIDC)', () => {
1717
let aliceWebId = 'https://localhost:7000/profile/card#me'
1818
let configPath = path.join(__dirname, '../../config')
1919
let aliceDbPath = path.join(__dirname,
20-
'../resources/accounts-scenario/alice/db/oidc')
21-
let userStorePath = path.join(aliceDbPath, 'users')
20+
'../resources/accounts-scenario/alice/db')
21+
let userStorePath = path.join(aliceDbPath, 'oidc/users')
2222
let aliceUserStore = UserStore.from({ path: userStorePath, saltRounds: 1 })
2323
aliceUserStore.initCollections()
2424

2525
let bobServerUri = 'https://localhost:7001'
2626
let bobDbPath = path.join(__dirname,
27-
'../resources/accounts-scenario/bob/db/oidc')
27+
'../resources/accounts-scenario/bob/db')
2828

2929
const serverConfig = {
3030
sslKey: path.join(__dirname, '../keys/key.pem'),
@@ -71,6 +71,7 @@ describe('Authentication API (OIDC)', () => {
7171
after(() => {
7272
if (aliceServer) aliceServer.close()
7373
if (bobServer) bobServer.close()
74+
fs.removeSync(path.join(aliceDbPath, 'oidc/users'))
7475
})
7576

7677
describe('Provider Discovery (POST /api/auth/select-provider)', () => {
@@ -128,7 +129,7 @@ describe('Authentication API (OIDC)', () => {
128129
})
129130

130131
afterEach(() => {
131-
fs.removeSync(path.join(aliceDbPath, 'users/*'))
132+
fs.removeSync(path.join(aliceDbPath, 'users/users'))
132133
})
133134

134135
it('should login and be redirected to /authorize', (done) => {

test/integration/capability-discovery.js

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,44 @@ const expect = require('chai').expect
55
// In this test we always assume that we are Alice
66

77
describe('API', () => {
8-
let aliceServer
9-
let alice
10-
let serverUri = 'https://localhost:5000'
8+
let alice, aliceServer
119

12-
const alicePod = Solid.createServer({
13-
root: path.join(__dirname, '../resources/accounts-scenario/alice'),
10+
let aliceServerUri = 'https://localhost:5000'
11+
let configPath = path.join(__dirname, '../../config')
12+
let aliceDbPath = path.join(__dirname,
13+
'../resources/accounts-scenario/alice/db')
14+
15+
const serverConfig = {
1416
sslKey: path.join(__dirname, '../keys/key.pem'),
1517
sslCert: path.join(__dirname, '../keys/cert.pem'),
1618
auth: 'oidc',
17-
serverUri,
1819
dataBrowser: false,
1920
fileBrowser: false,
20-
webid: true
21-
})
21+
webid: true,
22+
idp: false,
23+
configPath
24+
}
25+
26+
const alicePod = Solid.createServer(
27+
Object.assign({
28+
root: path.join(__dirname, '../resources/accounts-scenario/alice'),
29+
serverUri: aliceServerUri,
30+
dbPath: aliceDbPath
31+
}, serverConfig)
32+
)
2233

23-
before((done) => {
24-
aliceServer = alicePod.listen(5000, done)
25-
alice = supertest(serverUri)
34+
function startServer (pod, port) {
35+
return new Promise((resolve) => {
36+
pod.listen(port, () => { resolve() })
37+
})
38+
}
39+
40+
before(() => {
41+
return Promise.all([
42+
startServer(alicePod, 5000)
43+
]).then(() => {
44+
alice = supertest(aliceServerUri)
45+
})
2646
})
2747

2848
after(() => {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"client_id":"2d7c299a1aa8e8cadb6a0bb93b6e7873","client_secret":"b2926a0f21cec49c906b7b7956cc44ce","redirect_uris":["https://localhost:7000/api/oidc/rp/https%3A%2F%2Flocalhost%3A7000"],"response_types":["code","id_token token","code id_token token"],"grant_types":["authorization_code","implicit","refresh_token","client_credentials"],"application_type":"web","client_name":"Solid OIDC RP for https://localhost:7000","id_token_signed_response_alg":"RS256","token_endpoint_auth_method":"client_secret_basic","default_max_age":86400,"post_logout_redirect_uris":["https://localhost:7000/goodbye"],"frontchannel_logout_session_required":false}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"client_id":"370f34992ebf2d00bc6b4a2bd3dd77fd","client_secret":"1fbd9aa5561f242e7f9b1f95910a722d","redirect_uris":["https://localhost:7001/api/oidc/rp/https%3A%2F%2Flocalhost%3A7000"],"response_types":["code","id_token token","code id_token token"],"grant_types":["authorization_code","implicit","refresh_token","client_credentials"],"application_type":"web","client_name":"Solid OIDC RP for https://localhost:7000","id_token_signed_response_alg":"RS256","token_endpoint_auth_method":"client_secret_basic","default_max_age":86400,"post_logout_redirect_uris":["https://localhost:7001/goodbye"],"frontchannel_logout_session_required":false}

0 commit comments

Comments
 (0)