@@ -10,7 +10,7 @@ chai.use(sinonChai)
10
10
chai . should ( )
11
11
12
12
const AccountTemplate = require ( '../../lib/models/account-template' )
13
-
13
+ const UserAccount = require ( '../../lib/models/user-account' )
14
14
const templatePath = path . join ( __dirname , '../../default-templates/new-account' )
15
15
const accountPath = path . join ( __dirname , '../resources/new-account' )
16
16
@@ -62,4 +62,71 @@ describe('AccountTemplate', () => {
62
62
} )
63
63
} )
64
64
} )
65
+
66
+ describe ( 'templateSubtitutionsFor()' , ( ) => {
67
+ it ( 'should not update the webid' , ( ) => {
68
+ const userAccount = new UserAccount ( {
69
+ webId : 'https://alice.example.com/#me' ,
70
+ email : 'alice@example.com' ,
71
+ name : 'Alice Q.'
72
+ } )
73
+
74
+ const substitutions = AccountTemplate . templateSubstitutionsFor ( userAccount )
75
+
76
+ expect ( substitutions . webId ) . to . equal ( '/#me' )
77
+ } )
78
+
79
+ it ( 'should not update the nested webid' , ( ) => {
80
+ const userAccount = new UserAccount ( {
81
+ webId : 'https://alice.example.com/alice/#me' ,
82
+ email : 'alice@example.com' ,
83
+ name : 'Alice Q.'
84
+ } )
85
+
86
+ const substitutions = AccountTemplate . templateSubstitutionsFor ( userAccount )
87
+
88
+ expect ( substitutions . webId ) . to . equal ( '/alice/#me' )
89
+ } )
90
+
91
+ it ( 'should update the webid' , ( ) => {
92
+ const userAccount = new UserAccount ( {
93
+ webId : 'http://localhost:8443/alice/#me' ,
94
+ email : 'alice@example.com' ,
95
+ name : 'Alice Q.'
96
+ } )
97
+
98
+ const substitutions = AccountTemplate . templateSubstitutionsFor ( userAccount )
99
+
100
+ expect ( substitutions . webId ) . to . equal ( '/alice/#me' )
101
+ } )
102
+ } )
103
+
104
+ describe ( 'creating account where webId does match server Uri?' , ( ) => {
105
+ it ( 'should have a relative uri for the base path rather than a complete uri' , ( ) => {
106
+ const userAccount = new UserAccount ( {
107
+ webId : 'http://localhost:8443/alice/#me' ,
108
+ email : 'alice@example.com' ,
109
+ name : 'Alice Q.'
110
+ } )
111
+
112
+ const substitutions = AccountTemplate . templateSubstitutionsFor ( userAccount )
113
+ const template = new AccountTemplate ( { substitutions } )
114
+ return AccountTemplate . copyTemplateDir ( templatePath , accountPath )
115
+ . then ( ( ) => {
116
+ return template . processAccount ( accountPath )
117
+ } ) . then ( ( ) => {
118
+ const profile = fs . readFileSync ( path . join ( accountPath , '/profile/card$.ttl' ) , 'utf8' )
119
+ expect ( profile ) . to . include ( '"Alice Q."' )
120
+ expect ( profile ) . to . include ( 'solid:oidcIssuer' )
121
+ // why does this need to be included?
122
+ // with the current configuration, 'host' for
123
+ // ldp is not set, therefore solid:oidcIssuer is empty
124
+ // expect(profile).to.include('<https://example.com>')
125
+
126
+ const rootAcl = fs . readFileSync ( path . join ( accountPath , '.acl' ) , 'utf8' )
127
+ expect ( rootAcl ) . to . include ( '<mailto:alice@' )
128
+ expect ( rootAcl ) . to . include ( '</alice/#me>' )
129
+ } )
130
+ } )
131
+ } )
65
132
} )
0 commit comments