@@ -8,15 +8,17 @@ const path = require('path')
88const fs = require ( 'fs-extra' )
99
1010describe ( 'AccountManager (OIDC account creation tests)' , function ( ) {
11- var serverUri = 'https://localhost:3457'
12- var host = 'localhost:3457'
13- var ldpHttpsServer
14- let rootPath = path . join ( __dirname , '../resources/accounts/' )
15- let configPath = path . join ( __dirname , '../resources/config' )
16- let dbPath = path . join ( __dirname , '../resources/accounts/db' )
11+ const port = 3457
12+ const serverUri = `https://localhost:${ port } `
13+ const host = `localhost:${ port } `
14+ const root = path . join ( __dirname , '../resources/accounts/' )
15+ const configPath = path . join ( __dirname , '../resources/config' )
16+ const dbPath = path . join ( __dirname , '../resources/accounts/db' )
17+
18+ let ldpHttpsServer
1719
1820 var ldp = ldnode . createServer ( {
19- root : rootPath ,
21+ root,
2022 configPath,
2123 sslKey : path . join ( __dirname , '../keys/key.pem' ) ,
2224 sslCert : path . join ( __dirname , '../keys/cert.pem' ) ,
@@ -25,19 +27,20 @@ describe('AccountManager (OIDC account creation tests)', function () {
2527 multiuser : true ,
2628 strictOrigin : true ,
2729 dbPath,
28- serverUri
30+ serverUri,
31+ enforceToc : true
2932 } )
3033
3134 before ( checkDnsSettings )
3235
3336 before ( function ( done ) {
34- ldpHttpsServer = ldp . listen ( 3457 , done )
37+ ldpHttpsServer = ldp . listen ( port , done )
3538 } )
3639
3740 after ( function ( ) {
3841 if ( ldpHttpsServer ) ldpHttpsServer . close ( )
3942 fs . removeSync ( path . join ( dbPath , 'oidc/users/users' ) )
40- cleanDir ( path . join ( rootPath , 'localhost' ) )
43+ cleanDir ( path . join ( root , 'localhost' ) )
4144 } )
4245
4346 var server = supertest ( serverUri )
@@ -93,45 +96,52 @@ describe('AccountManager (OIDC account creation tests)', function () {
9396 it ( 'should not create a WebID if it already exists' , function ( done ) {
9497 var subdomain = supertest ( 'https://nicola.' + host )
9598 subdomain . post ( '/api/accounts/new' )
96- . send ( 'username=nicola&password=12345' )
99+ . send ( 'username=nicola&password=12345&acceptToc=true ' )
97100 . expect ( 302 )
98101 . end ( ( err , res ) => {
99102 if ( err ) {
100103 return done ( err )
101104 }
102105 subdomain . post ( '/api/accounts/new' )
103- . send ( 'username=nicola&password=12345' )
106+ . send ( 'username=nicola&password=12345&acceptToc=true ' )
104107 . expect ( 400 )
105108 . end ( ( err ) => {
106109 done ( err )
107110 } )
108111 } )
109112 } )
110113
114+ it ( 'should not create WebID if T&C is not accepted' , ( done ) => {
115+ let subdomain = supertest ( 'https://nicola.' + host )
116+ subdomain . post ( '/api/accounts/new' )
117+ . send ( 'username=nicola&password=12345&acceptToc=false' )
118+ . expect ( 400 , done )
119+ } )
120+
111121 it ( 'should create the default folders' , function ( done ) {
112122 var subdomain = supertest ( 'https://nicola.' + host )
113123 subdomain . post ( '/api/accounts/new' )
114- . send ( 'username=nicola&password=12345' )
124+ . send ( 'username=nicola&password=12345&acceptToc=true ' )
115125 . expect ( 302 )
116126 . end ( function ( err ) {
117127 if ( err ) {
118128 return done ( err )
119129 }
120130 var domain = host . split ( ':' ) [ 0 ]
121131 var card = read ( path . join ( 'accounts/nicola.' + domain ,
122- 'profile/card' ) )
132+ 'profile/card' ) )
123133 var cardAcl = read ( path . join ( 'accounts/nicola.' + domain ,
124- 'profile/card.acl' ) )
134+ 'profile/card.acl' ) )
125135 var prefs = read ( path . join ( 'accounts/nicola.' + domain ,
126- 'settings/prefs.ttl' ) )
136+ 'settings/prefs.ttl' ) )
127137 var inboxAcl = read ( path . join ( 'accounts/nicola.' + domain ,
128- 'inbox/.acl' ) )
138+ 'inbox/.acl' ) )
129139 var rootMeta = read ( path . join ( 'accounts/nicola.' + domain , '.meta' ) )
130140 var rootMetaAcl = read ( path . join ( 'accounts/nicola.' + domain ,
131- '.meta.acl' ) )
141+ '.meta.acl' ) )
132142
133143 if ( domain && card && cardAcl && prefs && inboxAcl && rootMeta &&
134- rootMetaAcl ) {
144+ rootMetaAcl ) {
135145 done ( )
136146 } else {
137147 done ( new Error ( 'failed to create default files' ) )
@@ -142,7 +152,7 @@ describe('AccountManager (OIDC account creation tests)', function () {
142152 it ( 'should link WebID to the root account' , function ( done ) {
143153 var subdomain = supertest ( 'https://nicola.' + host )
144154 subdomain . post ( '/api/accounts/new' )
145- . send ( 'username=nicola&password=12345' )
155+ . send ( 'username=nicola&password=12345&acceptToc=true ' )
146156 . expect ( 302 )
147157 . end ( function ( err ) {
148158 if ( err ) {
@@ -236,3 +246,46 @@ describe('Single User signup page', () => {
236246 . end ( done )
237247 } )
238248} )
249+
250+ describe ( 'Signup page where Terms & Conditions are not being enforced' , ( ) => {
251+ const port = 3457
252+ const host = `localhost:${ port } `
253+ const root = path . join ( __dirname , '../resources/accounts/' )
254+ const configPath = path . join ( __dirname , '../resources/config' )
255+ const dbPath = path . join ( __dirname , '../resources/accounts/db' )
256+ const ldp = ldnode . createServer ( {
257+ port,
258+ root,
259+ configPath,
260+ sslKey : path . join ( __dirname , '../keys/key.pem' ) ,
261+ sslCert : path . join ( __dirname , '../keys/cert.pem' ) ,
262+ auth : 'oidc' ,
263+ webid : true ,
264+ multiuser : true ,
265+ strictOrigin : true ,
266+ enforceToc : false
267+ } )
268+ let ldpHttpsServer
269+
270+ before ( function ( done ) {
271+ ldpHttpsServer = ldp . listen ( port , done )
272+ } )
273+
274+ after ( function ( ) {
275+ if ( ldpHttpsServer ) ldpHttpsServer . close ( )
276+ fs . removeSync ( path . join ( dbPath , 'oidc/users/users' ) )
277+ cleanDir ( path . join ( root , 'localhost' ) )
278+ rm ( 'accounts/nicola.localhost' )
279+ } )
280+
281+ beforeEach ( function ( ) {
282+ rm ( 'accounts/nicola.localhost' )
283+ } )
284+
285+ it ( 'should not enforce T&C upon creating account' , function ( done ) {
286+ var subdomain = supertest ( 'https://nicola.' + host )
287+ subdomain . post ( '/api/accounts/new' )
288+ . send ( 'username=nicola&password=12345' )
289+ . expect ( 302 , done )
290+ } )
291+ } )
0 commit comments