Repository navigation
Expand file tree
/
Copy pathtest.js
More file actions
63 lines (51 loc) · 1.62 KB
/
Copy pathtest.js
File metadata and controls
63 lines (51 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const Account = require('./account.js')
const assert = require('assert')
module.exports = ()=>{
let admin = new Account()
let guest = new Account()
admin.set('admin1Id', 'admin_password1')
admin.set('admin2Id', 'admin_password2')
guest.set('guest1Id', 'guest_password1')
guest.set('guest2Id', 'guest_password2')
// Data storage check
assert(admin.getAll() !== undefined)
assert(guest.getAll() !== undefined)
// Unique ID collision check
assert(admin.get('admin1Id') === 'admin_password1')
assert(guest.get('admin1Id') === undefined)
// Remove private variables check
guest.remove('guest1Id')
assert(!guest.exist('guest1Id'))
// Remove all private variables check
admin.removeAll()
guest.removeAll()
assert(admin.getAll() === undefined)
assert(guest.getAll() === undefined)
// Confirm automatic deletion of
// unique store remaining directories
admin.set('1', 'item1')
admin.set('2', 'item2')
admin.remove('1')
admin.remove('2')
assert(admin.getAll() === undefined)
admin.set('3', 'item3')
assert(admin.getAll() !== undefined)
admin.removeAll()
// Prevent incorrect instance usage
try{
admin.wrongReference()
assert.fail()
}catch(e){}
// Impossible injection check
admin.inject = ()=>{
assert(typeof store === 'undefined')
assert(typeof storage === 'undefined')
}
admin.inject()
admin.vulnerable1(()=>{
assert(typeof store === 'undefined')
assert(typeof storage === 'undefined')
})
// Abuse prevent check
assert(!admin.vulnerable2())
}