Skip to content

Commit 4618210

Browse files
authored
Fix use of functions from shared features to new Karate version (#107)
* Fix use of functions from shared features to new Karate version * Disable disputed scenario
1 parent e5f29f8 commit 4618210

9 files changed

Lines changed: 50 additions & 49 deletions

File tree

.github/workflows/ci-config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ jobs:
1919
# Steps represent a sequence of tasks that will be executed as part of the job
2020
steps:
2121
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
22-
- uses: actions/checkout@v2
22+
- uses: actions/checkout@v4
2323

2424
# Run the report
2525
- name: Run coverage report
2626
run: ./coverage.sh -d .
27-
27+
2828
# Write index file
2929
- name: Create index.html
3030
run: |

protocol/content-negotiation/content-negotiation-named-graphs.feature

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ Feature: RDF documents containing named graphs can be stored and retrieved
1515
And match header Content-Type contains 'application/ld+json'
1616
And assert parse(response, 'application/ld+json', resource.url).contains(expected)
1717

18+
@ignore
1819
Scenario: Alice can GET the JSON-LD with named graph as TTL
20+
# The expected response is disputed - since TTL doesn't support Quads, the RDF spec suggests:
21+
# "If an RDF dataset is returned and the consumer is expecting an RDF graph, the consumer is expected to use the RDF dataset's default graph."
22+
# https://github.com/solid-contrib/specification-tests/pull/101#issuecomment-1491711705
1923
Given header Accept = 'text/turtle'
2024
When method GET
2125
Then status 200

web-access-control/protected-operation/common.feature

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,6 @@ Scenario:
99
return agentLowerCase !== 'public' ? clients[agentLowerCase].getAuthHeaders(method, url) : {}
1010
}
1111
"""
12-
* def resourcePermissions =
13-
"""
14-
function (modes) {
15-
if (modes && modes !== 'inherited' && modes !== 'no') {
16-
return Object.entries({ R: 'read', W: 'write', A: 'append', C: 'control' })
17-
.filter(([mode, permission]) => modes.includes(mode))
18-
.map(([mode, permission]) => permission)
19-
}
20-
return undefined
21-
}
22-
"""
2312
* def getRequestData =
2413
"""
2514
function (type) {
@@ -45,26 +34,34 @@ Scenario:
4534
}
4635
}
4736
"""
48-
* def resourceEntry =
49-
"""
50-
function (container, type) {
51-
switch (type) {
52-
case 'plain':
53-
return container.createResource('.txt', 'Hello', 'text/plain')
54-
case 'fictive':
55-
return container.reserveResource('.txt')
56-
case 'rdf':
57-
return container.createResource('.ttl', karate.readAsString('../fixtures/example.ttl'), 'text/turtle')
58-
case 'container':
59-
return container.createContainer()
60-
default:
61-
return undefined
62-
}
63-
}
64-
"""
6537
* def createResource =
6638
"""
6739
function (containerModes, resourceModes, resourceType, subject, agent) {
40+
// define local functions so they are accessible when called from other contexts
41+
resourcePermissions = (modes) => {
42+
if (modes && modes !== 'inherited' && modes !== 'no') {
43+
return Object.entries({ R: 'read', W: 'write', A: 'append', C: 'control' })
44+
.filter(([mode, permission]) => modes.includes(mode))
45+
.map(([mode, permission]) => permission)
46+
}
47+
return undefined
48+
}
49+
50+
resourceEntry = (container, type) => {
51+
switch (type) {
52+
case 'plain':
53+
return container.createResource('.txt', 'Hello', 'text/plain')
54+
case 'fictive':
55+
return container.reserveResource('.txt')
56+
case 'rdf':
57+
return container.createResource('.ttl', karate.readAsString('../fixtures/example.ttl'), 'text/turtle')
58+
case 'container':
59+
return container.createContainer()
60+
default:
61+
return undefined
62+
}
63+
}
64+
6865
const testContainerPermissions = resourcePermissions(containerModes)
6966
const testResourcePermissions = resourcePermissions(resourceModes)
7067
const testContainerInheritablePermissions = resourceModes === 'inherited'
@@ -115,5 +112,5 @@ Scenario:
115112
return testResource
116113
}
117114
"""
118-
* def getResource = (container, resource, type) => testResources[`${container}:${resource}:${type}`]
115+
* def getResourceKey = (container, resource, type) => `${container}:${resource}:${type}`
119116
* def testResources = resources.reduce((map, t) => { map[`${t.container}:${t.resource}:${t.type}`] = createResource(t.container, t.resource, t.type, subject, agent); return map;}, {})

web-access-control/protected-operation/read-access-agent.feature

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Feature: Only authenticated agents can read (and only that) a resource when gran
1515
* def utils = callonce read('common.feature') ({resources, subject: 'authenticated'})
1616

1717
Scenario Outline: <agent> <result> read a <type> resource (<method>), when an authenticated agent has <container> access to the container and <resource> access to the resource
18-
* def testResource = utils.getResource(container, resource, type)
18+
* def testResource = utils.testResources[utils.getResourceKey(container, resource, type)]
1919
Given url testResource.url
2020
And headers utils.authHeaders(method, testResource.url, agent)
2121
When method <method>
@@ -52,7 +52,7 @@ Feature: Only authenticated agents can read (and only that) a resource when gran
5252
| Public | cannot | HEAD | container | R | inherited | 401 |
5353

5454
Scenario Outline: <agent> <result> <method> to a <type> resource, when an authenticated agent has <container> access to the container and <resource> access to the resource
55-
* def testResource = utils.getResource(container, resource, type)
55+
* def testResource = utils.testResources[utils.getResourceKey(container, resource, type)]
5656
Given url testResource.url
5757
And headers utils.authHeaders(method, testResource.url, agent)
5858
And header Content-Type = 'text/turtle'
@@ -83,7 +83,7 @@ Feature: Only authenticated agents can read (and only that) a resource when gran
8383
| Public | cannot | POST | container | R | inherited | [401] |
8484

8585
Scenario Outline: <agent> <result> <method> to a <type> resource, when an authenticated agent has <container> access to the container and <resource> access to the resource
86-
* def testResource = utils.getResource(container, resource, type)
86+
* def testResource = utils.testResources[utils.getResourceKey(container, resource, type)]
8787
Given url testResource.url
8888
And headers utils.authHeaders(method, testResource.url, agent)
8989
And header Content-Type = 'text/n3'
@@ -104,7 +104,7 @@ Feature: Only authenticated agents can read (and only that) a resource when gran
104104
| Public | cannot | PATCH | container | R | inherited | 401 |
105105

106106
Scenario Outline: <agent> <result> <method> to a <type> resource, when an authenticated agent has <container> access to the container and <resource> access to the resource
107-
* def testResource = utils.getResource(container, resource, type)
107+
* def testResource = utils.testResources[utils.getResourceKey(container, resource, type)]
108108
Given url testResource.url
109109
And headers utils.authHeaders(method, testResource.url, agent)
110110
And header Content-Type = 'text/plain'
@@ -133,7 +133,7 @@ Feature: Only authenticated agents can read (and only that) a resource when gran
133133
| Public | cannot | PATCH | fictive | R | inherited | [401, 405, 415] |
134134

135135
Scenario Outline: <agent> <result> <method> a <type> resource, when an authenticated agent has <container> access to the container and <resource> access to the resource
136-
* def testResource = utils.getResource(container, resource, type)
136+
* def testResource = utils.testResources[utils.getResourceKey(container, resource, type)]
137137
Given url testResource.url
138138
And headers utils.authHeaders(method, testResource.url, agent)
139139
When method <method>

web-access-control/protected-operation/read-access-bob.feature

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Feature: Only Bob can read (and only that) a resource when granted read access
1515
* def utils = callonce read('common.feature') ({resources, subject: 'agent', agent: webIds.bob})
1616

1717
Scenario Outline: <agent> <result> read a <type> resource (<method>), when Bob has <container> access to the container and <resource> access to the resource
18-
* def testResource = utils.getResource(container, resource, type)
18+
* def testResource = utils.testResources[utils.getResourceKey(container, resource, type)]
1919
Given url testResource.url
2020
And headers utils.authHeaders(method, testResource.url, agent)
2121
When method <method>
@@ -52,7 +52,7 @@ Feature: Only Bob can read (and only that) a resource when granted read access
5252
| Public | cannot | HEAD | container | R | inherited | 401 |
5353

5454
Scenario Outline: <agent> <result> <method> to a <type> resource, when Bob has <container> access to the container and <resource> access to the resource
55-
* def testResource = utils.getResource(container, resource, type)
55+
* def testResource = utils.testResources[utils.getResourceKey(container, resource, type)]
5656
Given url testResource.url
5757
And headers utils.authHeaders(method, testResource.url, agent)
5858
And header Content-Type = 'text/turtle'
@@ -83,7 +83,7 @@ Feature: Only Bob can read (and only that) a resource when granted read access
8383
| Public | cannot | POST | container | R | inherited | [401] |
8484

8585
Scenario Outline: <agent> <result> <method> to a <type> resource, when Bob has <container> access to the container and <resource> access to the resource
86-
* def testResource = utils.getResource(container, resource, type)
86+
* def testResource = utils.testResources[utils.getResourceKey(container, resource, type)]
8787
Given url testResource.url
8888
And headers utils.authHeaders(method, testResource.url, agent)
8989
And header Content-Type = 'text/n3'
@@ -104,7 +104,7 @@ Feature: Only Bob can read (and only that) a resource when granted read access
104104
| Public | cannot | PATCH | container | R | inherited | 401 |
105105

106106
Scenario Outline: <agent> <result> <method> to a <type> resource, when Bob has <container> access to the container and <resource> access to the resource
107-
* def testResource = utils.getResource(container, resource, type)
107+
* def testResource = utils.testResources[utils.getResourceKey(container, resource, type)]
108108
Given url testResource.url
109109
And headers utils.authHeaders(method, testResource.url, agent)
110110
And header Content-Type = 'text/plain'
@@ -133,7 +133,7 @@ Feature: Only Bob can read (and only that) a resource when granted read access
133133
| Public | cannot | PATCH | fictive | R | inherited | [401, 405, 415] |
134134

135135
Scenario Outline: <agent> <result> <method> a <type> resource, when Bob has <container> access to the container and <resource> access to the resource
136-
* def testResource = utils.getResource(container, resource, type)
136+
* def testResource = utils.testResources[utils.getResourceKey(container, resource, type)]
137137
Given url testResource.url
138138
And headers utils.authHeaders(method, testResource.url, agent)
139139
When method <method>

web-access-control/protected-operation/read-access-public.feature

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Feature: Public agents can read (and only that) a resource when granted read acc
1515
* def utils = callonce read('common.feature') ({resources, subject: 'public'})
1616

1717
Scenario Outline: <agent> <result> read a <type> resource (<method>), when a public agent has <container> access to the container and <resource> access to the resource
18-
* def testResource = utils.getResource(container, resource, type)
18+
* def testResource = utils.testResources[utils.getResourceKey(container, resource, type)]
1919
Given url testResource.url
2020
And headers utils.authHeaders(method, testResource.url, agent)
2121
When method <method>
@@ -56,7 +56,7 @@ Feature: Public agents can read (and only that) a resource when granted read acc
5656
| Public | can | HEAD | container | R | inherited | 200 |
5757

5858
Scenario Outline: <agent> <result> <method> to a <type> resource, when a public agent has <container> access to the container and <resource> access to the resource
59-
* def testResource = utils.getResource(container, resource, type)
59+
* def testResource = utils.testResources[utils.getResourceKey(container, resource, type)]
6060
Given url testResource.url
6161
And headers utils.authHeaders(method, testResource.url, agent)
6262
And header Content-Type = 'text/turtle'
@@ -87,7 +87,7 @@ Feature: Public agents can read (and only that) a resource when granted read acc
8787
| Public | cannot | POST | container | R | inherited | [401] |
8888

8989
Scenario Outline: <agent> <result> <method> to a <type> resource, when a public agent has <container> access to the container and <resource> access to the resource
90-
* def testResource = utils.getResource(container, resource, type)
90+
* def testResource = utils.testResources[utils.getResourceKey(container, resource, type)]
9191
Given url testResource.url
9292
And headers utils.authHeaders(method, testResource.url, agent)
9393
And header Content-Type = 'text/n3'
@@ -108,7 +108,7 @@ Feature: Public agents can read (and only that) a resource when granted read acc
108108
| Public | cannot | PATCH | container | R | inherited | 401 |
109109

110110
Scenario Outline: <agent> <result> <method> to a <type> resource, when a public agent has <container> access to the container and <resource> access to the resource
111-
* def testResource = utils.getResource(container, resource, type)
111+
* def testResource = utils.testResources[utils.getResourceKey(container, resource, type)]
112112
Given url testResource.url
113113
And headers utils.authHeaders(method, testResource.url, agent)
114114
And header Content-Type = 'text/plain'
@@ -137,7 +137,7 @@ Feature: Public agents can read (and only that) a resource when granted read acc
137137
| Public | cannot | PATCH | fictive | R | inherited | [401, 405, 415] |
138138

139139
Scenario Outline: <agent> <result> <method> a <type> resource, when a public agent has <container> access to the container and <resource> access to the resource
140-
* def testResource = utils.getResource(container, resource, type)
140+
* def testResource = utils.testResources[utils.getResourceKey(container, resource, type)]
141141
Given url testResource.url
142142
And headers utils.authHeaders(method, testResource.url, agent)
143143
When method <method>

web-access-control/protected-operation/write-access-agent.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Feature: Only authenticated agents can write (and only that) a resource when gra
1515
* def utils = callonce read('common.feature') ({resources, subject: 'authenticated'})
1616

1717
Scenario Outline: <agent> <result> read a <type> resource (<method>), when an authenticated agent has <container> access to the container and <resource> access to the resource
18-
* def testResource = utils.getResource(container, resource, type)
18+
* def testResource = utils.testResources[utils.getResourceKey(container, resource, type)]
1919
Given url testResource.url
2020
And headers utils.authHeaders(method, testResource.url, agent)
2121
When method <method>

web-access-control/protected-operation/write-access-bob.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Feature: Only Bob can write (and only that) a resource when granted write access
1515
* def utils = callonce read('common.feature') ({resources, subject: 'agent', agent: webIds.bob})
1616

1717
Scenario Outline: <agent> <result> read a <type> resource (<method>), when Bob has <container> access to the container and <resource> access to the resource
18-
* def testResource = utils.getResource(container, resource, type)
18+
* def testResource = utils.testResources[utils.getResourceKey(container, resource, type)]
1919
Given url testResource.url
2020
And headers utils.authHeaders(method, testResource.url, agent)
2121
When method <method>

web-access-control/protected-operation/write-access-public.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Feature: Only authenticated agents can write (and only that) a resource when gra
1515
* def utils = callonce read('common.feature') ({resources, subject: 'public'})
1616

1717
Scenario Outline: <agent> <result> read a <type> resource (<method>), when a public agent has <container> access to the container and <resource> access to the resource
18-
* def testResource = utils.getResource(container, resource, type)
18+
* def testResource = utils.testResources[utils.getResourceKey(container, resource, type)]
1919
Given url testResource.url
2020
When method <method>
2121
Then status <status>

0 commit comments

Comments
 (0)