@things-factory/shell 10.1.79 → 10.1.106

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/shell",
3
- "version": "10.1.79",
3
+ "version": "10.1.106",
4
4
  "description": "Core module for framework",
5
5
  "bin": {
6
6
  "things-factory": "bin/things-factory",
@@ -126,5 +126,5 @@
126
126
  "pg": "^8.7.3",
127
127
  "sqlite3": "^5.0.8"
128
128
  },
129
- "gitHead": "94cde9ba17dfdddb0a16139b71e5a7e370977e4a"
129
+ "gitHead": "8d78c14708420773ec32d18b8dd44c300771c44d"
130
130
  }
@@ -42,3 +42,29 @@ describe('domain middleware - an address the domain does not let in', () => {
42
42
  expect(await run(undefined, '10.0.0.1')).toEqual({ status: 200, headers: {}, passed: true })
43
43
  })
44
44
  })
45
+
46
+ describe('domain middleware - privileges the protected list withholds say they were the address', () => {
47
+ function stateAfter(iplist: any, ip: string) {
48
+ const context: any = {
49
+ state: { domain: { id: 'd1', iplist } },
50
+ req: { headers: { 'x-client-ip': ip }, connection: {}, socket: {} },
51
+ status: 200,
52
+ set: () => {}
53
+ }
54
+ return domainMiddleware(context, async () => {}).then(() => context.state)
55
+ }
56
+
57
+ const iplist = { protectedlist: ['^10\\.'], privileges: [{ category: 'board', privilege: 'mutation' }] }
58
+
59
+ it('★ outside the protected list each withheld privilege carries by: address (ADR-0103 decision 1)', async () => {
60
+ const state = await stateAfter(iplist, '192.168.0.9')
61
+ expect(state.unsafeIP).toBe(true)
62
+ expect(state.prohibitedPrivileges).toEqual([{ category: 'board', privilege: 'mutation', by: 'address' }])
63
+ })
64
+
65
+ it('inside the protected list nothing is withheld', async () => {
66
+ const state = await stateAfter(iplist, '10.0.0.1')
67
+ expect(state.unsafeIP).toBe(false)
68
+ expect(state.prohibitedPrivileges).toBeUndefined()
69
+ })
70
+ })