Skip to content

Commit 9d6b23f

Browse files
committed
Should not remove dirs in test...
1 parent a408b58 commit 9d6b23f

File tree

9 files changed

+28
-25
lines changed

9 files changed

+28
-25
lines changed

test/integration/account-creation-oidc-test.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const supertest = require('supertest')
22
// Helper functions for the FS
33
const $rdf = require('rdflib')
44

5-
const { rm, read, checkDnsSettings } = require('../utils')
5+
const { rm, read, checkDnsSettings, cleanDir } = require('../utils')
66
const ldnode = require('../../index')
77
const path = require('path')
88
const fs = require('fs-extra')
@@ -37,8 +37,7 @@ describe('AccountManager (OIDC account creation tests)', function () {
3737
after(function () {
3838
if (ldpHttpsServer) ldpHttpsServer.close()
3939
fs.removeSync(path.join(dbPath, 'oidc/users/users'))
40-
fs.removeSync(path.join(rootPath, 'localhost'))
41-
fs.removeSync(path.join(rootPath, 'localhost'))
40+
cleanDir(path.join(rootPath, 'localhost'))
4241
})
4342

4443
var server = supertest(serverUri)

test/integration/acl-oidc-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const assert = require('chai').assert
22
const fs = require('fs-extra')
33
const request = require('request')
44
const path = require('path')
5-
const { loadProvider, rm, checkDnsSettings } = require('../utils')
5+
const { loadProvider, rm, checkDnsSettings, cleanDir } = require('../utils')
66
const IDToken = require('@solid/oidc-op/src/IDToken')
77

88
const ldnode = require('../../index')
@@ -86,7 +86,7 @@ describe('ACL with WebID+OIDC over HTTP', function () {
8686

8787
after(() => {
8888
if (ldpHttpsServer) ldpHttpsServer.close()
89-
fs.removeSync(path.join(rootPath))
89+
cleanDir(rootPath)
9090
})
9191

9292
const origin1 = 'http://example.org/'

test/integration/acl-tls-test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ var fs = require('fs-extra')
33
var $rdf = require('rdflib')
44
var request = require('request')
55
var path = require('path')
6+
var { cleanDir } = require('../utils')
67

78
/**
89
* Note: this test suite requires an internet connection, since it actually
@@ -69,7 +70,7 @@ describe('ACL with WebID+TLS', function () {
6970

7071
after(function () {
7172
if (ldpHttpsServer) ldpHttpsServer.close()
72-
fs.removeSync(path.join(rootPath))
73+
cleanDir(rootPath)
7374
})
7475

7576
function createOptions (path, user) {

test/integration/auth-proxy-test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const path = require('path')
33
const nock = require('nock')
44
const request = require('supertest')
55
const { expect } = require('chai')
6-
const rmDir = require('../utils').rmDir
6+
const rm = require('../utils').rm
77

88
const USER = 'https://ruben.verborgh.org/profile/#me'
99

@@ -32,7 +32,8 @@ describe('Auth Proxy', () => {
3232
// Release back-end server
3333
nock.cleanAll()
3434
// Remove created index files
35-
rmDir()
35+
rm('index.html')
36+
rm('index.html.acl')
3637
})
3738

3839
describe('responding to /server/a', () => {

test/integration/authentication-oidc-test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const localStorage = require('localstorage-memory')
1010
const URL = require('whatwg-url').URL
1111
global.URL = URL
1212
global.URLSearchParams = require('whatwg-url').URLSearchParams
13+
const { cleanDir } = require('../utils')
1314

1415
const supertest = require('supertest')
1516
const chai = require('chai')
@@ -81,8 +82,8 @@ describe('Authentication API (OIDC)', () => {
8182
alicePod.close()
8283
bobPod.close()
8384
fs.removeSync(path.join(aliceDbPath, 'oidc/users'))
84-
fs.removeSync(path.join(aliceRootPath))
85-
fs.removeSync(path.join(bobRootPath))
85+
cleanDir(aliceRootPath)
86+
cleanDir(bobRootPath)
8687
})
8788

8889
describe('Login page (GET /login)', () => {

test/integration/capability-discovery-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const Solid = require('../../index')
22
const path = require('path')
3-
const fs = require('fs-extra')
3+
const { cleanDir } = require('../utils')
44
const supertest = require('supertest')
55
const expect = require('chai').expect
66
// In this test we always assume that we are Alice
@@ -48,7 +48,7 @@ describe('API', () => {
4848

4949
after(() => {
5050
alicePod.close()
51-
fs.removeSync(path.join(aliceRootPath))
51+
cleanDir(aliceRootPath)
5252
})
5353

5454
describe('Capability Discovery', () => {

test/integration/errors-oidc-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const supertest = require('supertest')
22
const ldnode = require('../../index')
33
const path = require('path')
4-
const fs = require('fs-extra')
4+
const { cleanDir } = require('../utils')
55
const expect = require('chai').expect
66

77
describe('OIDC error handling', function () {
@@ -30,7 +30,7 @@ describe('OIDC error handling', function () {
3030

3131
after(function () {
3232
if (ldpHttpsServer) ldpHttpsServer.close()
33-
fs.removeSync(path.join(rootPath))
33+
cleanDir(rootPath)
3434
})
3535

3636
const server = supertest(serverUri)

test/integration/params-test.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
var assert = require('chai').assert
22
var supertest = require('supertest')
33
var path = require('path')
4-
const fs = require('fs-extra')
54
// Helper functions for the FS
6-
var rm = require('../utils').rm
7-
var write = require('../utils').write
8-
// var cp = require('./utils').cp
9-
var read = require('../utils').read
5+
const { rm, write, read, cleanDir } = require('../utils')
106

117
var ldnode = require('../../index')
128

@@ -127,7 +123,7 @@ describe('LDNODE params', function () {
127123

128124
after(function () {
129125
if (ldpHttpsServer) ldpHttpsServer.close()
130-
fs.removeSync(path.join(rootPath))
126+
cleanDir(rootPath)
131127
})
132128

133129
var server = supertest(serverUri)

test/utils.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
var fs = require('fs')
2-
var fsExtra = require('fs-extra')
1+
var fs = require('fs-extra')
32
var rimraf = require('rimraf')
43
var path = require('path')
54
const OIDCProvider = require('@solid/oidc-op')
@@ -11,16 +10,22 @@ exports.rm = function (file) {
1110
return rimraf.sync(path.join(__dirname, '/resources/' + file))
1211
}
1312

14-
exports.rmDir = function (path = '') {
15-
return rimraf.sync(path.join(__dirname, '/resources/' + path))
13+
exports.cleanDir = function (dirPath) {
14+
fs.removeSync(path.join(dirPath, '.well-known/.acl'))
15+
fs.removeSync(path.join(dirPath, 'favicon.ico'))
16+
fs.removeSync(path.join(dirPath, 'favicon.ico.acl'))
17+
fs.removeSync(path.join(dirPath, 'index.html'))
18+
fs.removeSync(path.join(dirPath, 'index.html.acl'))
19+
fs.removeSync(path.join(dirPath, 'robots.txt'))
20+
fs.removeSync(path.join(dirPath, 'robots.txt.acl'))
1621
}
1722

1823
exports.write = function (text, file) {
1924
return fs.writeFileSync(path.join(__dirname, '/resources/' + file), text)
2025
}
2126

2227
exports.cp = function (src, dest) {
23-
return fsExtra.copySync(
28+
return fs.copySync(
2429
path.join(__dirname, '/resources/' + src),
2530
path.join(__dirname, '/resources/' + dest))
2631
}

0 commit comments

Comments
 (0)