solid-logic 3.1.1-fafcec1 → 4.0.0-3e8294e
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/README.md +129 -2
- package/dist/acl/aclLogic.d.ts +5 -0
- package/{lib → dist}/acl/aclLogic.d.ts.map +1 -1
- package/dist/acl/aclLogic.js +117 -0
- package/dist/acl/aclLogic.js.map +1 -0
- package/dist/authSession/authSession.js +3 -0
- package/dist/authSession/authSession.js.map +1 -0
- package/{lib → dist}/authn/SolidAuthnLogic.d.ts +3 -3
- package/{lib → dist}/authn/SolidAuthnLogic.d.ts.map +1 -1
- package/dist/authn/SolidAuthnLogic.js +109 -0
- package/dist/authn/SolidAuthnLogic.js.map +1 -0
- package/{lib → dist}/authn/authUtil.d.ts +1 -1
- package/dist/authn/authUtil.d.ts.map +1 -0
- package/dist/authn/authUtil.js +64 -0
- package/dist/authn/authUtil.js.map +1 -0
- package/{lib → dist}/chat/chatLogic.d.ts +1 -1
- package/{lib → dist}/chat/chatLogic.d.ts.map +1 -1
- package/dist/chat/chatLogic.js +157 -0
- package/dist/chat/chatLogic.js.map +1 -0
- package/{lib → dist}/inbox/inboxLogic.d.ts +1 -1
- package/{lib → dist}/inbox/inboxLogic.d.ts.map +1 -1
- package/dist/inbox/inboxLogic.js +51 -0
- package/dist/inbox/inboxLogic.js.map +1 -0
- package/{lib → dist}/index.d.ts +1 -1
- package/{lib → dist}/index.d.ts.map +1 -1
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/issuer/issuerLogic.js +37 -0
- package/dist/issuer/issuerLogic.js.map +1 -0
- package/{lib → dist}/logic/CustomError.d.ts.map +1 -1
- package/dist/logic/CustomError.js +27 -0
- package/dist/logic/CustomError.js.map +1 -0
- package/dist/logic/solidLogic.d.ts +6 -0
- package/{lib → dist}/logic/solidLogic.d.ts.map +1 -1
- package/dist/logic/solidLogic.js +64 -0
- package/dist/logic/solidLogic.js.map +1 -0
- package/dist/logic/solidLogicSingleton.d.ts +4 -0
- package/{lib → dist}/logic/solidLogicSingleton.d.ts.map +1 -1
- package/dist/logic/solidLogicSingleton.js +31 -0
- package/dist/logic/solidLogicSingleton.js.map +1 -0
- package/{lib → dist}/profile/profileLogic.d.ts +1 -1
- package/{lib → dist}/profile/profileLogic.d.ts.map +1 -1
- package/dist/profile/profileLogic.js +128 -0
- package/dist/profile/profileLogic.js.map +1 -0
- package/dist/solid-logic.esm.js +7356 -0
- package/dist/solid-logic.esm.js.map +1 -0
- package/dist/solid-logic.esm.min.js +32 -0
- package/dist/solid-logic.esm.min.js.map +1 -0
- package/dist/solid-logic.js +7415 -0
- package/dist/solid-logic.js.map +1 -0
- package/dist/solid-logic.min.js +32 -0
- package/dist/solid-logic.min.js.map +1 -0
- package/{lib → dist}/typeIndex/typeIndexLogic.d.ts.map +1 -1
- package/dist/typeIndex/typeIndexLogic.js +182 -0
- package/dist/typeIndex/typeIndexLogic.js.map +1 -0
- package/{lib → dist}/types.d.ts +2 -2
- package/{lib → dist}/types.d.ts.map +1 -1
- package/dist/types.js +2 -0
- package/{lib → dist}/util/containerLogic.d.ts +1 -1
- package/{lib → dist}/util/containerLogic.d.ts.map +1 -1
- package/{src/util/containerLogic.ts → dist/util/containerLogic.js} +15 -23
- package/dist/util/containerLogic.js.map +1 -0
- package/dist/util/debug.d.ts.map +1 -0
- package/dist/util/debug.js +13 -0
- package/dist/util/debug.js.map +1 -0
- package/dist/util/ns.js +5 -0
- package/dist/util/ns.js.map +1 -0
- package/{lib → dist}/util/utilityLogic.d.ts +1 -1
- package/{lib → dist}/util/utilityLogic.d.ts.map +1 -1
- package/dist/util/utilityLogic.js +144 -0
- package/dist/util/utilityLogic.js.map +1 -0
- package/{lib → dist}/util/utils.d.ts +1 -1
- package/{lib → dist}/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js +39 -0
- package/dist/util/utils.js.map +1 -0
- package/dist/versionInfo.js +30 -0
- package/dist/versionInfo.js.map +1 -0
- package/package.json +51 -23
- package/eslint.config.js +0 -29
- package/jest.config.js +0 -10
- package/lib/acl/aclLogic.d.ts +0 -5
- package/lib/acl/aclLogic.js +0 -168
- package/lib/acl/aclLogic.js.map +0 -1
- package/lib/authSession/authSession.js +0 -6
- package/lib/authSession/authSession.js.map +0 -1
- package/lib/authn/SolidAuthnLogic.js +0 -193
- package/lib/authn/SolidAuthnLogic.js.map +0 -1
- package/lib/authn/authUtil.d.ts.map +0 -1
- package/lib/authn/authUtil.js +0 -105
- package/lib/authn/authUtil.js.map +0 -1
- package/lib/chat/chatLogic.js +0 -272
- package/lib/chat/chatLogic.js.map +0 -1
- package/lib/inbox/inboxLogic.js +0 -139
- package/lib/inbox/inboxLogic.js.map +0 -1
- package/lib/index.js +0 -31
- package/lib/index.js.map +0 -1
- package/lib/issuer/issuerLogic.js +0 -52
- package/lib/issuer/issuerLogic.js.map +0 -1
- package/lib/logic/CustomError.js +0 -89
- package/lib/logic/CustomError.js.map +0 -1
- package/lib/logic/solidLogic.d.ts +0 -6
- package/lib/logic/solidLogic.js +0 -102
- package/lib/logic/solidLogic.js.map +0 -1
- package/lib/logic/solidLogicSingleton.d.ts +0 -3
- package/lib/logic/solidLogicSingleton.js +0 -94
- package/lib/logic/solidLogicSingleton.js.map +0 -1
- package/lib/profile/profileLogic.js +0 -259
- package/lib/profile/profileLogic.js.map +0 -1
- package/lib/typeIndex/typeIndexLogic.js +0 -399
- package/lib/typeIndex/typeIndexLogic.js.map +0 -1
- package/lib/types.js +0 -3
- package/lib/util/containerLogic.js +0 -102
- package/lib/util/containerLogic.js.map +0 -1
- package/lib/util/debug.d.ts.map +0 -1
- package/lib/util/debug.js +0 -40
- package/lib/util/debug.js.map +0 -1
- package/lib/util/ns.js +0 -44
- package/lib/util/ns.js.map +0 -1
- package/lib/util/utilityLogic.js +0 -284
- package/lib/util/utilityLogic.js.map +0 -1
- package/lib/util/utils.js +0 -47
- package/lib/util/utils.js.map +0 -1
- package/src/acl/aclLogic.ts +0 -156
- package/src/authSession/authSession.ts +0 -7
- package/src/authn/SolidAuthnLogic.ts +0 -127
- package/src/authn/authUtil.ts +0 -70
- package/src/chat/chatLogic.ts +0 -226
- package/src/inbox/inboxLogic.ts +0 -59
- package/src/index.ts +0 -22
- package/src/issuer/issuerLogic.ts +0 -40
- package/src/logic/CustomError.ts +0 -29
- package/src/logic/solidLogic.ts +0 -76
- package/src/logic/solidLogicSingleton.ts +0 -20
- package/src/profile/profileLogic.ts +0 -125
- package/src/typeIndex/typeIndexLogic.ts +0 -198
- package/src/types.ts +0 -122
- package/src/util/debug.ts +0 -20
- package/src/util/ns.ts +0 -5
- package/src/util/utilityLogic.ts +0 -156
- package/src/util/utils.ts +0 -52
- package/test/aclLogic.test.ts +0 -24
- package/test/authUtil.test.ts +0 -23
- package/test/chatLogic.test.ts +0 -316
- package/test/container.test.ts +0 -58
- package/test/helpers/dataSetup.ts +0 -134
- package/test/helpers/setup.ts +0 -17
- package/test/inboxLogic.test.ts +0 -218
- package/test/logic.test.ts +0 -29
- package/test/profileLogic.test.ts +0 -246
- package/test/solidAuthLogic.test.ts +0 -49
- package/test/typeIndexLogic.test.ts +0 -255
- package/test/utilityLogic.test.ts +0 -179
- package/test/utils.test.ts +0 -32
- package/tsconfig.json +0 -75
- /package/{lib → dist}/authSession/authSession.d.ts +0 -0
- /package/{lib → dist}/authSession/authSession.d.ts.map +0 -0
- /package/{lib → dist}/issuer/issuerLogic.d.ts +0 -0
- /package/{lib → dist}/issuer/issuerLogic.d.ts.map +0 -0
- /package/{lib → dist}/logic/CustomError.d.ts +0 -0
- /package/{lib → dist}/typeIndex/typeIndexLogic.d.ts +0 -0
- /package/{lib → dist}/types.js.map +0 -0
- /package/{lib → dist}/util/debug.d.ts +0 -0
- /package/{lib → dist}/util/ns.d.ts +0 -0
- /package/{lib → dist}/util/ns.d.ts.map +0 -0
package/test/inboxLogic.test.ts
DELETED
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jest-environment jsdom
|
|
3
|
-
*
|
|
4
|
-
*/
|
|
5
|
-
import { UpdateManager, Store, Fetcher, sym } from "rdflib";
|
|
6
|
-
import { createAclLogic } from "../src/acl/aclLogic";
|
|
7
|
-
import { createInboxLogic } from '../src/inbox/inboxLogic';
|
|
8
|
-
import { createProfileLogic } from "../src/profile/profileLogic";
|
|
9
|
-
import { createContainerLogic } from "../src/util/containerLogic";
|
|
10
|
-
import { createUtilityLogic } from "../src/util/utilityLogic";
|
|
11
|
-
|
|
12
|
-
const alice = sym("https://alice.example.com/profile/card#me");
|
|
13
|
-
const bob = sym("https://bob.example.com/profile/card#me");
|
|
14
|
-
|
|
15
|
-
describe("Inbox logic", () => {
|
|
16
|
-
let store;
|
|
17
|
-
let inboxLogic
|
|
18
|
-
beforeEach(() => {
|
|
19
|
-
fetchMock.resetMocks();
|
|
20
|
-
fetchMock.mockResponse("Not Found", {
|
|
21
|
-
status: 404,
|
|
22
|
-
});
|
|
23
|
-
store = new Store()
|
|
24
|
-
store.fetcher = new Fetcher(store, { fetch: fetch });
|
|
25
|
-
store.updater = new UpdateManager(store);
|
|
26
|
-
const authn = {
|
|
27
|
-
currentUser: () => {
|
|
28
|
-
return alice;
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
const containerLogic = createContainerLogic(store)
|
|
32
|
-
const aclLogic = createAclLogic(store)
|
|
33
|
-
const util = createUtilityLogic(store, aclLogic, containerLogic);
|
|
34
|
-
const profile = createProfileLogic(store, authn, util);
|
|
35
|
-
inboxLogic = createInboxLogic(store, profile, util, containerLogic, aclLogic);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
describe("getNewMessages", () => {
|
|
39
|
-
describe("When inbox is empty", () => {
|
|
40
|
-
let result;
|
|
41
|
-
beforeEach(async () => {
|
|
42
|
-
bobHasAnInbox();
|
|
43
|
-
inboxIsEmpty();
|
|
44
|
-
result = await inboxLogic.getNewMessages(bob);
|
|
45
|
-
});
|
|
46
|
-
it("Resolves to an empty array", () => {
|
|
47
|
-
expect(result).toEqual([]);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
describe("When container has some containment triples", () => {
|
|
51
|
-
let result;
|
|
52
|
-
beforeEach(async () => {
|
|
53
|
-
bobHasAnInbox();
|
|
54
|
-
inboxHasSomeContainmentTriples();
|
|
55
|
-
const messages = await inboxLogic.getNewMessages(bob);
|
|
56
|
-
result = messages.map(oneMessage => oneMessage.value)
|
|
57
|
-
});
|
|
58
|
-
it("Resolves to an array with URLs of non-container resources in inbox", () => {
|
|
59
|
-
expect(result.sort()).toEqual([
|
|
60
|
-
'https://container.com/foo.txt'
|
|
61
|
-
].sort());
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
describe('createInboxFor', () => {
|
|
66
|
-
beforeEach(async () => {
|
|
67
|
-
aliceHasValidProfile();
|
|
68
|
-
// First for the PUT:
|
|
69
|
-
fetchMock.mockOnceIf(
|
|
70
|
-
"https://alice.example.com/p2p-inboxes/Peer%20Person/",
|
|
71
|
-
"Created", {
|
|
72
|
-
status: 201
|
|
73
|
-
}
|
|
74
|
-
)
|
|
75
|
-
// Then for the GET to read the ACL link:
|
|
76
|
-
fetchMock.mockOnceIf(
|
|
77
|
-
"https://alice.example.com/p2p-inboxes/Peer%20Person/",
|
|
78
|
-
" ", {
|
|
79
|
-
status: 200,
|
|
80
|
-
headers: {
|
|
81
|
-
Link: '<https://some/acl>; rel="acl"',
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
)
|
|
85
|
-
fetchMock.mockIf("https://some/acl", "Created", { status: 201 });
|
|
86
|
-
|
|
87
|
-
await inboxLogic.createInboxFor('https://peer.com/#me', 'Peer Person');
|
|
88
|
-
});
|
|
89
|
-
it("creates the inbox", () => {
|
|
90
|
-
expect(fetchMock.mock.calls).toEqual([
|
|
91
|
-
[ "https://alice.example.com/profile/card", fetchMock.mock.calls[0][1] ],
|
|
92
|
-
[ "https://alice.example.com/p2p-inboxes/Peer%20Person/", {
|
|
93
|
-
body: " ",
|
|
94
|
-
headers: {
|
|
95
|
-
"Content-Type": "text/turtle",
|
|
96
|
-
"If-None-Match": "*",
|
|
97
|
-
Link: "<http://www.w3.org/ns/ldp#BasicContainer>; rel=\"type\"",
|
|
98
|
-
},
|
|
99
|
-
method: "PUT"
|
|
100
|
-
}],
|
|
101
|
-
[ "https://alice.example.com/p2p-inboxes/Peer%20Person/", fetchMock.mock.calls[2][1] ],
|
|
102
|
-
[ "https://some/acl", {
|
|
103
|
-
body: '@prefix acl: <http://www.w3.org/ns/auth/acl#>.\n' +
|
|
104
|
-
'\n' +
|
|
105
|
-
'<#alice> a acl:Authorization;\n' +
|
|
106
|
-
' acl:agent <https://alice.example.com/profile/card#me>;\n' +
|
|
107
|
-
' acl:accessTo <https://alice.example.com/p2p-inboxes/Peer%20Person/>;\n' +
|
|
108
|
-
' acl:default <https://alice.example.com/p2p-inboxes/Peer%20Person/>;\n' +
|
|
109
|
-
' acl:mode acl:Read, acl:Write, acl:Control.\n' +
|
|
110
|
-
'<#bobAccessTo> a acl:Authorization;\n' +
|
|
111
|
-
' acl:agent <https://peer.com/#me>;\n' +
|
|
112
|
-
' acl:accessTo <https://alice.example.com/p2p-inboxes/Peer%20Person/>;\n' +
|
|
113
|
-
' acl:mode acl:Append.\n',
|
|
114
|
-
headers: [
|
|
115
|
-
[ 'Content-Type', 'text/turtle' ]
|
|
116
|
-
],
|
|
117
|
-
method: 'PUT'
|
|
118
|
-
}]
|
|
119
|
-
]);
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
});
|
|
123
|
-
describe('markAsRead', () => {
|
|
124
|
-
beforeEach(async () => {
|
|
125
|
-
fetchMock.mockOnceIf(
|
|
126
|
-
"https://container.com/item.ttl",
|
|
127
|
-
"<#some> <#inbox> <#item> .",
|
|
128
|
-
{
|
|
129
|
-
headers: { "Content-Type": "text/turtle" },
|
|
130
|
-
}
|
|
131
|
-
);
|
|
132
|
-
fetchMock.mockOnceIf(
|
|
133
|
-
"https://container.com/archive/2111/03/31/item.ttl",
|
|
134
|
-
"Created",
|
|
135
|
-
{
|
|
136
|
-
status: 201,
|
|
137
|
-
headers: { "Content-Type": "text/turtle" },
|
|
138
|
-
}
|
|
139
|
-
);
|
|
140
|
-
await inboxLogic.markAsRead("https://container.com/item.ttl", new Date('31 March 2111 UTC'));
|
|
141
|
-
});
|
|
142
|
-
it('moves the item to archive', async () => {
|
|
143
|
-
expect(fetchMock.mock.calls).toEqual([
|
|
144
|
-
[ "https://container.com/item.ttl" ],
|
|
145
|
-
[
|
|
146
|
-
"https://container.com/archive/2111/03/31/item.ttl",
|
|
147
|
-
{
|
|
148
|
-
"body": "<#some> <#inbox> <#item> .",
|
|
149
|
-
"headers": [
|
|
150
|
-
[
|
|
151
|
-
"Content-Type",
|
|
152
|
-
"text/turtle",
|
|
153
|
-
],
|
|
154
|
-
],
|
|
155
|
-
"method": "PUT",
|
|
156
|
-
},
|
|
157
|
-
],
|
|
158
|
-
[ "https://container.com/item.ttl", { method: 'DELETE' } ],
|
|
159
|
-
]);
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
function aliceHasValidProfile() {
|
|
164
|
-
fetchMock.mockOnceIf(
|
|
165
|
-
"https://alice.example.com/profile/card",
|
|
166
|
-
`
|
|
167
|
-
<https://alice.example.com/profile/card#me>
|
|
168
|
-
<http://www.w3.org/ns/pim/space#storage> <https://alice.example.com/> ;
|
|
169
|
-
<http://www.w3.org/ns/solid/terms#privateTypeIndex> <https://alice.example.com/settings/privateTypeIndex.ttl> ;
|
|
170
|
-
.`,
|
|
171
|
-
{
|
|
172
|
-
headers: {
|
|
173
|
-
"Content-Type": "text/turtle",
|
|
174
|
-
},
|
|
175
|
-
}
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
function bobHasAnInbox() {
|
|
180
|
-
fetchMock.mockOnceIf(
|
|
181
|
-
"https://bob.example.com/profile/card",
|
|
182
|
-
"<https://bob.example.com/profile/card#me><http://www.w3.org/ns/ldp#inbox><https://container.com/>.",
|
|
183
|
-
{
|
|
184
|
-
headers: { "Content-Type": "text/turtle" },
|
|
185
|
-
}
|
|
186
|
-
);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
function inboxIsEmpty() {
|
|
190
|
-
fetchMock.mockOnceIf(
|
|
191
|
-
"https://container.com/",
|
|
192
|
-
" ", // FIXME: https://github.com/jefflau/jest-fetch-mock/issues/189
|
|
193
|
-
{
|
|
194
|
-
headers: { "Content-Type": "text/turtle" },
|
|
195
|
-
}
|
|
196
|
-
);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
function inboxHasSomeContainmentTriples() {
|
|
200
|
-
fetchMock.mockOnceIf(
|
|
201
|
-
"https://container.com/",
|
|
202
|
-
"<.> <http://www.w3.org/ns/ldp#contains> <./foo.txt>, <./bar/> .",
|
|
203
|
-
{
|
|
204
|
-
headers: { "Content-Type": "text/turtle" },
|
|
205
|
-
}
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
function inboxItemExists() {
|
|
210
|
-
fetchMock.mockOnceIf(
|
|
211
|
-
"https://container.com/item.ttl",
|
|
212
|
-
"<#some> <#inbox> <#item> .",
|
|
213
|
-
{
|
|
214
|
-
headers: { "Content-Type": "text/turtle" },
|
|
215
|
-
}
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
});
|
package/test/logic.test.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { solidLogicSingleton } from "../src/logic/solidLogicSingleton"
|
|
2
|
-
import { silenceDebugMessages } from "./helpers/setup"
|
|
3
|
-
|
|
4
|
-
silenceDebugMessages()
|
|
5
|
-
|
|
6
|
-
describe('store', () => {
|
|
7
|
-
it('exists', () => {
|
|
8
|
-
expect(solidLogicSingleton.store).toBeInstanceOf(Object)
|
|
9
|
-
})
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
describe('store.fetcher', () => {
|
|
13
|
-
it('exists', () => {
|
|
14
|
-
expect(solidLogicSingleton.store.fetcher).toBeInstanceOf(Object)
|
|
15
|
-
})
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
describe('store.updater', () => {
|
|
19
|
-
it('exists', () => {
|
|
20
|
-
expect(solidLogicSingleton.store.updater).toBeInstanceOf(Object)
|
|
21
|
-
})
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
describe('authn', () => {
|
|
25
|
-
it('exists', () => {
|
|
26
|
-
expect(solidLogicSingleton.authn).toBeInstanceOf(Object)
|
|
27
|
-
})
|
|
28
|
-
})
|
|
29
|
-
|
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jest-environment jsdom
|
|
3
|
-
*
|
|
4
|
-
*/
|
|
5
|
-
import { UpdateManager, Store, Fetcher } from 'rdflib';
|
|
6
|
-
import { createProfileLogic } from "../src/profile/profileLogic";
|
|
7
|
-
import { createUtilityLogic } from "../src/util/utilityLogic"
|
|
8
|
-
import { ns } from "../src/util/ns";
|
|
9
|
-
import {
|
|
10
|
-
alice, AlicePreferencesFile, AlicePrivateTypeIndex, AliceProfileFile, bob, boby, loadWebObject
|
|
11
|
-
} from './helpers/dataSetup';
|
|
12
|
-
import { createAclLogic } from "../src/acl/aclLogic";
|
|
13
|
-
import { createContainerLogic } from "../src/util/containerLogic";
|
|
14
|
-
|
|
15
|
-
const prefixes = Object.keys(ns).map(prefix => `@prefix ${prefix}: ${ns[prefix]('')}.\n`).join('') // In turtle
|
|
16
|
-
const user = alice
|
|
17
|
-
const profile = user.doc()
|
|
18
|
-
let requests = []
|
|
19
|
-
let profileLogic
|
|
20
|
-
|
|
21
|
-
describe("Profile", () => {
|
|
22
|
-
|
|
23
|
-
describe('loadProfile', () => {
|
|
24
|
-
window.$SolidTestEnvironment = { username: alice.uri }
|
|
25
|
-
let store
|
|
26
|
-
requests = []
|
|
27
|
-
const statustoBeReturned = 200
|
|
28
|
-
let web = {}
|
|
29
|
-
const authn = {
|
|
30
|
-
currentUser: () => {
|
|
31
|
-
return alice;
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
beforeEach(() => {
|
|
35
|
-
fetchMock.resetMocks();
|
|
36
|
-
web = loadWebObject()
|
|
37
|
-
requests = []
|
|
38
|
-
fetchMock.mockIf(/^https?.*$/, async req => {
|
|
39
|
-
|
|
40
|
-
if (req.method !== 'GET') {
|
|
41
|
-
requests.push(req)
|
|
42
|
-
if (req.method === 'PUT') {
|
|
43
|
-
const contents = await req.text()
|
|
44
|
-
web[req.url] = contents // Update our dummy web
|
|
45
|
-
console.log(`Tetst: Updated ${req.url} on PUT to <<<${web[req.url]}>>>`)
|
|
46
|
-
}
|
|
47
|
-
return { status: statustoBeReturned }
|
|
48
|
-
}
|
|
49
|
-
const contents = web[req.url]
|
|
50
|
-
if (contents !== undefined) { //
|
|
51
|
-
return {
|
|
52
|
-
body: prefixes + contents, // Add namespaces to anything
|
|
53
|
-
status: 200,
|
|
54
|
-
headers: {
|
|
55
|
-
"Content-Type": "text/turtle",
|
|
56
|
-
"WAC-Allow": 'user="write", public="read"',
|
|
57
|
-
"Accept-Patch": "application/sparql-update"
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
} // if contents
|
|
61
|
-
return {
|
|
62
|
-
status: 404,
|
|
63
|
-
body: 'Not Found'
|
|
64
|
-
}
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
store = new Store()
|
|
68
|
-
store.fetcher = new Fetcher(store, { fetch: fetch });
|
|
69
|
-
store.updater = new UpdateManager(store);
|
|
70
|
-
const util = createUtilityLogic(store, createAclLogic(store), createContainerLogic(store))
|
|
71
|
-
profileLogic = createProfileLogic(store, authn, util)
|
|
72
|
-
})
|
|
73
|
-
it('exists', () => {
|
|
74
|
-
expect(profileLogic.loadProfile).toBeInstanceOf(Function)
|
|
75
|
-
})
|
|
76
|
-
it('loads data', async () => {
|
|
77
|
-
const result = await profileLogic.loadProfile(user)
|
|
78
|
-
expect(result).toBeInstanceOf(Object)
|
|
79
|
-
expect(result.uri).toEqual(AliceProfileFile.uri)
|
|
80
|
-
expect(store.holds(user, ns.rdf('type'), ns.vcard('Individual'), profile)).toEqual(true)
|
|
81
|
-
expect(store.holds(user, ns.space('preferencesFile'), AlicePreferencesFile, profile)).toEqual(true)
|
|
82
|
-
expect(store.statementsMatching(null, null, null, profile).length).toEqual(4)
|
|
83
|
-
})
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
describe('silencedLoadPreferences', () => {
|
|
87
|
-
window.$SolidTestEnvironment = { username: alice.uri }
|
|
88
|
-
let store
|
|
89
|
-
requests = []
|
|
90
|
-
const statustoBeReturned = 200
|
|
91
|
-
let web = {}
|
|
92
|
-
const authn = {
|
|
93
|
-
currentUser: () => {
|
|
94
|
-
return alice;
|
|
95
|
-
},
|
|
96
|
-
};
|
|
97
|
-
beforeEach(() => {
|
|
98
|
-
fetchMock.resetMocks();
|
|
99
|
-
web = loadWebObject()
|
|
100
|
-
requests = []
|
|
101
|
-
fetchMock.mockIf(/^https?.*$/, async req => {
|
|
102
|
-
|
|
103
|
-
if (req.method !== 'GET') {
|
|
104
|
-
requests.push(req)
|
|
105
|
-
if (req.method === 'PUT') {
|
|
106
|
-
const contents = await req.text()
|
|
107
|
-
web[req.url] = contents // Update our dummy web
|
|
108
|
-
console.log(`Tetst: Updated ${req.url} on PUT to <<<${web[req.url]}>>>`)
|
|
109
|
-
}
|
|
110
|
-
return { status: statustoBeReturned }
|
|
111
|
-
}
|
|
112
|
-
const contents = web[req.url]
|
|
113
|
-
if (contents !== undefined) { //
|
|
114
|
-
return {
|
|
115
|
-
body: prefixes + contents, // Add namespaces to anything
|
|
116
|
-
status: 200,
|
|
117
|
-
headers: {
|
|
118
|
-
"Content-Type": "text/turtle",
|
|
119
|
-
"WAC-Allow": 'user="write", public="read"',
|
|
120
|
-
"Accept-Patch": "application/sparql-update"
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
} // if contents
|
|
124
|
-
return {
|
|
125
|
-
status: 404,
|
|
126
|
-
body: 'Not Found'
|
|
127
|
-
}
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
store = new Store()
|
|
131
|
-
store.fetcher = new Fetcher(store, { fetch: fetch });
|
|
132
|
-
store.updater = new UpdateManager(store);
|
|
133
|
-
const util = createUtilityLogic(store, createAclLogic(store), createContainerLogic(store))
|
|
134
|
-
profileLogic = createProfileLogic(store, authn, util)
|
|
135
|
-
})
|
|
136
|
-
it('exists', () => {
|
|
137
|
-
expect(profileLogic.silencedLoadPreferences).toBeInstanceOf(Function)
|
|
138
|
-
})
|
|
139
|
-
it('loads data', async () => {
|
|
140
|
-
const result = await profileLogic.silencedLoadPreferences(alice)
|
|
141
|
-
expect(result).toBeInstanceOf(Object)
|
|
142
|
-
expect(result.uri).toEqual(AlicePreferencesFile.uri)
|
|
143
|
-
expect(store.holds(user, ns.rdf('type'), ns.vcard('Individual'), profile)).toEqual(true)
|
|
144
|
-
expect(store.statementsMatching(null, null, null, profile).length).toEqual(4)
|
|
145
|
-
|
|
146
|
-
expect(store.statementsMatching(null, null, null, AlicePreferencesFile).length).toEqual(2)
|
|
147
|
-
expect(store.holds(user, ns.solid('privateTypeIndex'), AlicePrivateTypeIndex, AlicePreferencesFile)).toEqual(true)
|
|
148
|
-
})
|
|
149
|
-
it('creates new file', async () => {
|
|
150
|
-
const result = await profileLogic.silencedLoadPreferences(bob)
|
|
151
|
-
|
|
152
|
-
const patchRequest = requests[0]
|
|
153
|
-
expect(patchRequest.method).toEqual('PATCH')
|
|
154
|
-
expect(patchRequest.url).toEqual(bob.doc().uri)
|
|
155
|
-
const text = await patchRequest.text()
|
|
156
|
-
expect(text).toContain('INSERT DATA { <https://bob.example.com/profile/card.ttl#me> <http://www.w3.org/ns/pim/space#preferencesFile> <https://bob.example.com/Settings/Preferences.ttl> .')
|
|
157
|
-
|
|
158
|
-
const putRequest = requests[1]
|
|
159
|
-
expect(putRequest.method).toEqual('PUT')
|
|
160
|
-
expect(putRequest.url).toEqual('https://bob.example.com/Settings/Preferences.ttl')
|
|
161
|
-
expect(web[putRequest.url]).toEqual('')
|
|
162
|
-
|
|
163
|
-
})
|
|
164
|
-
})
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
describe('loadPreferences', () => {
|
|
168
|
-
window.$SolidTestEnvironment = { username: boby.uri }
|
|
169
|
-
let store
|
|
170
|
-
requests = []
|
|
171
|
-
const statustoBeReturned = 200
|
|
172
|
-
let web = {}
|
|
173
|
-
const authn = {
|
|
174
|
-
currentUser: () => {
|
|
175
|
-
return boby;
|
|
176
|
-
},
|
|
177
|
-
};
|
|
178
|
-
beforeEach(() => {
|
|
179
|
-
fetchMock.resetMocks();
|
|
180
|
-
web = loadWebObject()
|
|
181
|
-
requests = []
|
|
182
|
-
fetchMock.mockIf(/^https?.*$/, async req => {
|
|
183
|
-
|
|
184
|
-
if (req.method !== 'GET') {
|
|
185
|
-
requests.push(req)
|
|
186
|
-
if (req.method === 'PUT') {
|
|
187
|
-
const contents = await req.text()
|
|
188
|
-
web[req.url] = contents // Update our dummy web
|
|
189
|
-
console.log(`Tetst: Updated ${req.url} on PUT to <<<${web[req.url]}>>>`)
|
|
190
|
-
}
|
|
191
|
-
return { status: statustoBeReturned }
|
|
192
|
-
}
|
|
193
|
-
const contents = web[req.url]
|
|
194
|
-
if (contents !== undefined) { //
|
|
195
|
-
return {
|
|
196
|
-
body: prefixes + contents, // Add namespaces to anything
|
|
197
|
-
status: 200,
|
|
198
|
-
headers: {
|
|
199
|
-
"Content-Type": "text/turtle",
|
|
200
|
-
"WAC-Allow": 'user="write", public="read"',
|
|
201
|
-
"Accept-Patch": "application/sparql-update"
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
} // if contents
|
|
205
|
-
return {
|
|
206
|
-
status: 404,
|
|
207
|
-
body: 'Not Found'
|
|
208
|
-
}
|
|
209
|
-
})
|
|
210
|
-
|
|
211
|
-
store = new Store()
|
|
212
|
-
store.fetcher = new Fetcher(store, { fetch: fetch });
|
|
213
|
-
store.updater = new UpdateManager(store);
|
|
214
|
-
const util = createUtilityLogic(store, createAclLogic(store), createContainerLogic(store))
|
|
215
|
-
profileLogic = createProfileLogic(store, authn, util)
|
|
216
|
-
})
|
|
217
|
-
it('exists', () => {
|
|
218
|
-
expect(profileLogic.loadPreferences).toBeInstanceOf(Function)
|
|
219
|
-
})
|
|
220
|
-
it('loads data', async () => {
|
|
221
|
-
const result = await profileLogic.loadPreferences(alice)
|
|
222
|
-
expect(result).toBeInstanceOf(Object)
|
|
223
|
-
expect(result.uri).toEqual(AlicePreferencesFile.uri)
|
|
224
|
-
expect(store.holds(user, ns.rdf('type'), ns.vcard('Individual'), profile)).toEqual(true)
|
|
225
|
-
expect(store.statementsMatching(null, null, null, profile).length).toEqual(4)
|
|
226
|
-
|
|
227
|
-
expect(store.statementsMatching(null, null, null, AlicePreferencesFile).length).toEqual(2)
|
|
228
|
-
expect(store.holds(user, ns.solid('privateTypeIndex'), AlicePrivateTypeIndex, AlicePreferencesFile)).toEqual(true)
|
|
229
|
-
})
|
|
230
|
-
it('creates new file', async () => {
|
|
231
|
-
const result = await profileLogic.loadPreferences(boby)
|
|
232
|
-
|
|
233
|
-
const patchRequest = requests[0]
|
|
234
|
-
expect(patchRequest.method).toEqual('PATCH')
|
|
235
|
-
expect(patchRequest.url).toEqual(boby.doc().uri)
|
|
236
|
-
const text = await patchRequest.text()
|
|
237
|
-
expect(text).toContain('INSERT DATA { <https://boby.example.com/profile/card.ttl#me> <http://www.w3.org/ns/pim/space#preferencesFile> <https://boby.example.com/Settings/Preferences.ttl> .')
|
|
238
|
-
|
|
239
|
-
const putRequest = requests[1]
|
|
240
|
-
expect(putRequest.method).toEqual('PUT')
|
|
241
|
-
expect(putRequest.url).toEqual('https://boby.example.com/Settings/Preferences.ttl')
|
|
242
|
-
expect(web[putRequest.url]).toEqual('')
|
|
243
|
-
|
|
244
|
-
})
|
|
245
|
-
})
|
|
246
|
-
})
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jest-environment jsdom
|
|
3
|
-
*
|
|
4
|
-
*/
|
|
5
|
-
import { SolidAuthnLogic } from '../src/authn/SolidAuthnLogic'
|
|
6
|
-
import { silenceDebugMessages } from './helpers/setup'
|
|
7
|
-
import { authSession } from '../src/authSession/authSession'
|
|
8
|
-
import { AuthenticationContext } from '../src/types'
|
|
9
|
-
|
|
10
|
-
silenceDebugMessages()
|
|
11
|
-
let solidAuthnLogic
|
|
12
|
-
|
|
13
|
-
describe("SolidAuthnLogic", () => {
|
|
14
|
-
|
|
15
|
-
beforeEach(() => {
|
|
16
|
-
solidAuthnLogic = new SolidAuthnLogic(authSession)
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
describe('checkUser', () => {
|
|
20
|
-
it('exists', () => {
|
|
21
|
-
expect(solidAuthnLogic.checkUser).toBeInstanceOf(Function)
|
|
22
|
-
})
|
|
23
|
-
it('runs', async () => {
|
|
24
|
-
expect(await solidAuthnLogic.checkUser()).toEqual(null)
|
|
25
|
-
})
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
describe('currentUser', () => {
|
|
29
|
-
it('exists', () => {
|
|
30
|
-
expect(solidAuthnLogic.currentUser).toBeInstanceOf(Function)
|
|
31
|
-
})
|
|
32
|
-
it('runs', async () => {
|
|
33
|
-
expect(await solidAuthnLogic.currentUser()).toEqual(null)
|
|
34
|
-
})
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
describe('saveUser', () => {
|
|
38
|
-
it('exists', () => {
|
|
39
|
-
expect(solidAuthnLogic.saveUser).toBeInstanceOf(Function)
|
|
40
|
-
})
|
|
41
|
-
it('runs', () => {
|
|
42
|
-
expect(solidAuthnLogic.saveUser(
|
|
43
|
-
'',
|
|
44
|
-
{} as AuthenticationContext
|
|
45
|
-
)).toEqual(null)
|
|
46
|
-
})
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
})
|