Skip to content

Commit 8ec204b

Browse files
author
deiu
committed
Renamed secure-test.js > acl.js. Added depth to defaultForNew test. Fixed cleanup tests (sync).
1 parent 8999b70 commit 8ec204b

2 files changed

Lines changed: 23 additions & 36 deletions

File tree

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"start": "node bin/ldnode.js",
5959
"test": "./node_modules/mocha/bin/mocha ./test/*.js",
6060
"test-debug": "DEBUG='ldnode:*' ./node_modules/mocha/bin/mocha ./test/*.js",
61-
"test-acl": "./node_modules/mocha/bin/mocha ./test/secure-test.js",
61+
"test-acl": "./node_modules/mocha/bin/mocha ./test/acl.js",
6262
"test-params": "./node_modules/mocha/bin/mocha ./test/params.js",
6363
"test-http": "./node_modules/mocha/bin/mocha ./test/test.js"
6464
},
Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ describe('ACL', function() {
2929

3030
var testDir = 'acl/testDir';
3131
var testDirAclFile = testDir + '/' + aclExtension;
32+
var testDirMetaFile = testDir + '/' + metaExtension;
3233

3334
var abcFile = testDir + '/abc.ttl';
3435
var abcAclFile = abcFile + aclExtension;
35-
var abcdFile = testDir + '/abcd.ttl';
36+
var abcdFile = testDir + '/dir1/dir2/abcd.ttl';
3637
var abcdAclFile = abcFile + aclExtension;
3738

3839
var globFile = testDir + "/*";
@@ -87,7 +88,7 @@ describe('ACL', function() {
8788

8889
describe("Empty ACL Test", function() {
8990
it("Should create test folder", function(done) {
90-
var options = createOptions(testDir + '/' + metaExtension, 'user1');
91+
var options = createOptions(testDirMetaFile, 'user1');
9192
options.body = "";
9293
request.put(options, function(error, response, body) {
9394
assert.equal(error, null);
@@ -828,7 +829,7 @@ describe('ACL', function() {
828829
});
829830

830831
describe("ACL defaultForNew test", function() {
831-
var body = "<#Owner>\n" +
832+
var body = "<#Owner>\n" +
832833
" <http://www.w3.org/ns/auth/acl#accessTo> <" + address + testDir + "/" + ">, <" +
833834
address + testDirAclFile + ">;\n" +
834835
" <http://www.w3.org/ns/auth/acl#agent> <" + user1 + ">;\n" +
@@ -928,6 +929,7 @@ describe('ACL', function() {
928929
});
929930
});
930931
});
932+
931933
describe("WebID delegation tests", function() {
932934
it("user1 should be able delegate to user2", function(done) {
933935
var body = "<" + user1 + "> <http://www.w3.org/ns/auth/acl#delegates> <" + user2 +"> .";
@@ -961,38 +963,23 @@ describe('ACL', function() {
961963
// });
962964
// });
963965
});
964-
describe("Clean-up test", function() {
965-
it("user1 should remove abcd test file", function(done) {
966-
var options = createOptions(abcdFile, 'user1');
967-
request.del(options, function(error, response, body) {
968-
assert.equal(error, null);
969-
assert.equal(response.statusCode, 200);
970-
done();
971-
});
972-
});
973-
it("user1 should remove abc test file", function(done) {
974-
var options = createOptions(abcFile, 'user1');
975-
request.del(options, function(error, response, body) {
976-
assert.equal(error, null);
977-
assert.equal(response.statusCode, 200);
978-
done();
979-
});
980-
});
981-
it("user1 should remove test folder's ACL file", function(done) {
982-
var options = createOptions(testDirAclFile, 'user1');
983-
request.del(options, function(error, response, body) {
984-
assert.equal(error, null);
985-
assert.equal(response.statusCode, 200);
986-
done();
987-
});
988-
});
989-
it("user1 should remove test folder", function(done) {
990-
var options = createOptions(testDir, 'user1');
991-
request.del(options, function(error, response, body) {
992-
assert.equal(error, null);
993-
assert.equal(response.statusCode, 200);
994-
done();
995-
});
966+
967+
describe("ACL cleaup", function() {
968+
it("should remove all files and dirs created", function(done) {
969+
try {
970+
// must remove the ACLs in sync
971+
fs.unlinkSync(__dirname + '/' + testDir + '/dir1/dir2/abcd.ttl');
972+
fs.rmdirSync(__dirname + '/' + testDir + '/dir1/dir2/');
973+
fs.rmdirSync(__dirname + '/' + testDir + '/dir1/');
974+
fs.unlinkSync(__dirname + '/' + abcFile);
975+
fs.unlinkSync(__dirname + '/' + testDirAclFile);
976+
fs.unlinkSync(__dirname + '/' + testDirMetaFile);
977+
fs.rmdirSync(__dirname + '/' + testDir);
978+
fs.rmdirSync(__dirname + '/acl/');
979+
done();
980+
} catch (e) {
981+
done(e);
982+
}
996983
});
997984
});
998985
});

0 commit comments

Comments
 (0)