@@ -150,5 +150,47 @@ describe('A server setup', (): void => {
150150
151151 expect ( response . status ) . toBe ( 201 ) ;
152152 } ) ;
153+
154+ it ( 'RS: does not allow public read access to the new resource.' , async ( ) : Promise < void > => {
155+ const response = await fetch ( collectionResource ) ;
156+ expect ( response . status ) . toBe ( 401 ) ;
157+ } ) ;
158+
159+ it ( 'the resource can be made publicly accessible by having an anonymous assignee.' , async ( ) : Promise < void > => {
160+ const owner = 'https://pod.woutslabbinck.com/profile/card#me' ;
161+ const url = `http://localhost:${ umaPort } /uma/policies` ;
162+
163+ const policy = `
164+ @prefix ex: <http://example.org/>.
165+ @prefix odrl: <http://www.w3.org/ns/odrl/2/> .
166+
167+ ex:publicPolicy a odrl:Agreement ;
168+ odrl:uid ex:publicPolicy ;
169+ odrl:permission ex:publicPermission .
170+ ex:publicPermission a odrl:Permission ;
171+ odrl:action odrl:read , odrl:modify ;
172+ odrl:target <${ collectionResource } > ;
173+ odrl:assignee <urn:solidlab:uma:id:anonymous> ;
174+ odrl:assigner <${ owner } > .
175+ ` ;
176+
177+ const policyResponse = await fetch ( url , {
178+ method : 'POST' ,
179+ headers : { authorization : owner , 'content-type' : 'text/turtle' } ,
180+ body : policy ,
181+ } ) ;
182+ expect ( policyResponse . status ) . toBe ( 201 ) ;
183+
184+ const putResponse = await fetch ( collectionResource , {
185+ method : 'PUT' ,
186+ headers : { 'content-type' : 'text/plain' } ,
187+ body : 'Some new text!' ,
188+ } ) ;
189+ expect ( putResponse . status ) . toBe ( 205 ) ;
190+
191+ const getResponse = await fetch ( collectionResource ) ;
192+ expect ( getResponse . status ) . toBe ( 200 ) ;
193+ await expect ( getResponse . text ( ) ) . resolves . toEqual ( 'Some new text!' ) ;
194+ } ) ;
153195 } ) ;
154196} ) ;
0 commit comments