This repository has been archived by the owner on Aug 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f8a8fa5
commit 865de49
Showing
3 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
@prefix : <https://michielbdejong.com/profile/card#>. | ||
@prefix acl: <http://www.w3.org/ns/auth/acl#>. | ||
|
||
:me | ||
acl:trustedApp | ||
[ | ||
acl:mode acl:Append, acl:Read, acl:Write; | ||
acl:origin <https://pheyvaer.github.io> | ||
]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import rdf from 'rdf-ext' | ||
import N3Parser from 'rdf-parser-n3' | ||
import fs from 'fs' | ||
import { appIsTrustedForMode, OriginCheckTask } from '../../../src/lib/auth/appIsTrustedForMode' | ||
import { RdfFetcher } from '../../../src/lib/rdf/RdfFetcher' | ||
import { ACL } from '../../../src/lib/rdf/rdf-constants' | ||
|
||
function readFixture (filename: string): Promise<any> { | ||
const bodyStream = fs.createReadStream(filename) | ||
let parser = new N3Parser({ | ||
factory: rdf | ||
}) | ||
let quadStream = parser.import(bodyStream) | ||
return rdf.dataset().import(quadStream) | ||
|
||
} | ||
test('finds acl:trustedApps nodes and their modes for a given owners list', async () => { | ||
const task = { | ||
origin: 'https://pheyvaer.github.io', | ||
mode: ACL.Read, | ||
resourceOwners: [ new URL('https://michielbdejong.com/profile/card#me')] | ||
} as OriginCheckTask | ||
|
||
const rdfFetcher: unknown = { | ||
fetchGraph: jest.fn(() => { | ||
return readFixture('test/fixtures/owner-profile.ttl') | ||
}) | ||
} | ||
const result = await appIsTrustedForMode(task, rdfFetcher as RdfFetcher) | ||
expect(result).toEqual(true) | ||
}) |