-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/solid/node-solid-server int…
…o main
- Loading branch information
Showing
5 changed files
with
75 additions
and
5 deletions.
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
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 |
---|---|---|
|
@@ -10,7 +10,7 @@ chai.use(sinonChai) | |
chai.should() | ||
|
||
const AccountTemplate = require('../../lib/models/account-template') | ||
|
||
const UserAccount = require('../../lib/models/user-account') | ||
const templatePath = path.join(__dirname, '../../default-templates/new-account') | ||
const accountPath = path.join(__dirname, '../resources/new-account') | ||
|
||
|
@@ -62,4 +62,71 @@ describe('AccountTemplate', () => { | |
}) | ||
}) | ||
}) | ||
|
||
describe('templateSubtitutionsFor()', () => { | ||
it('should not update the webid', () => { | ||
const userAccount = new UserAccount({ | ||
webId: 'https://alice.example.com/#me', | ||
email: '[email protected]', | ||
name: 'Alice Q.' | ||
}) | ||
|
||
const substitutions = AccountTemplate.templateSubstitutionsFor(userAccount) | ||
|
||
expect(substitutions.webId).to.equal('/#me') | ||
}) | ||
|
||
it('should not update the nested webid', () => { | ||
const userAccount = new UserAccount({ | ||
webId: 'https://alice.example.com/alice/#me', | ||
email: '[email protected]', | ||
name: 'Alice Q.' | ||
}) | ||
|
||
const substitutions = AccountTemplate.templateSubstitutionsFor(userAccount) | ||
|
||
expect(substitutions.webId).to.equal('/alice/#me') | ||
}) | ||
|
||
it('should update the webid', () => { | ||
const userAccount = new UserAccount({ | ||
webId: 'http://localhost:8443/alice/#me', | ||
email: '[email protected]', | ||
name: 'Alice Q.' | ||
}) | ||
|
||
const substitutions = AccountTemplate.templateSubstitutionsFor(userAccount) | ||
|
||
expect(substitutions.webId).to.equal('/alice/#me') | ||
}) | ||
}) | ||
|
||
describe('creating account where webId does match server Uri?', () => { | ||
it('should have a relative uri for the base path rather than a complete uri', () => { | ||
const userAccount = new UserAccount({ | ||
webId: 'http://localhost:8443/alice/#me', | ||
email: '[email protected]', | ||
name: 'Alice Q.' | ||
}) | ||
|
||
const substitutions = AccountTemplate.templateSubstitutionsFor(userAccount) | ||
const template = new AccountTemplate({ substitutions }) | ||
return AccountTemplate.copyTemplateDir(templatePath, accountPath) | ||
.then(() => { | ||
return template.processAccount(accountPath) | ||
}).then(() => { | ||
const profile = fs.readFileSync(path.join(accountPath, '/profile/card$.ttl'), 'utf8') | ||
expect(profile).to.include('"Alice Q."') | ||
expect(profile).to.include('solid:oidcIssuer') | ||
// why does this need to be included? | ||
// with the current configuration, 'host' for | ||
// ldp is not set, therefore solid:oidcIssuer is empty | ||
// expect(profile).to.include('<https://example.com>') | ||
|
||
const rootAcl = fs.readFileSync(path.join(accountPath, '.acl'), 'utf8') | ||
expect(rootAcl).to.include('<mailto:alice@') | ||
expect(rootAcl).to.include('</alice/#me>') | ||
}) | ||
}) | ||
}) | ||
}) |
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 |
---|---|---|
|
@@ -54,7 +54,7 @@ describe('AccountTemplate', () => { | |
const substitutions = AccountTemplate.templateSubstitutionsFor(userAccount) | ||
expect(substitutions.name).to.equal('Alice Q.') | ||
expect(substitutions.email).to.equal('[email protected]') | ||
expect(substitutions.webId).to.equal('https://alice.example.com/profile/card#me') | ||
expect(substitutions.webId).to.equal('/profile/card#me') | ||
}) | ||
}) | ||
}) |