This repository was archived by the owner on Feb 9, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprivate-api-config.yaml
More file actions
229 lines (212 loc) · 5.54 KB
/
private-api-config.yaml
File metadata and controls
229 lines (212 loc) · 5.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
plugin: openapi
specFile: ./private-api.yaml
pickFirstIfNoneMatch: false
validation:
request: true
system:
stores:
questions:
preloadFile: data/questions.json
resources:
### 'insufficient-questions' journey ###
- method: POST
path: /session
requestBody:
jsonPath: $.client_id
value: "insufficient-questions"
response:
statusCode: 201
template: true
content: |
{
"session_id": "insufficient-questions",
"state": "sT@t3",
"redirect_uri": "http://example.net"
}
- method: POST
path: /fetchquestions
requestHeaders:
session-id: insufficient-questions
response:
statusCode: 400
content: |
{
"redirect_uri": "http://example.net",
"oauth_error": {
"error_description": "Invalid request",
"error": "invalid_request"
}
}
### 'question-500' journey ###
- method: GET
path: /question
requestHeaders:
session-id: question-500
response:
statusCode: 500
template: true
content: Server Error
### 'answer-500' journey ###
- method: POST
path: /answer
requestHeaders:
session-id: answer-500
response:
statusCode: 500
template: true
content: Server Error
### 'authorization-error' journey ###
- method: POST
path: /session
requestBody:
jsonPath: $.client_id
value: "authorization-error"
response:
statusCode: 201
template: true
content: |
{
"session_id": "authorization-error",
"state": "sT@t3",
"redirect_uri": "http://example.net"
}
- method: GET
path: /question
requestHeaders:
session-id: "authorization-error"
response:
statusCode: 204
- method: GET
path: /authorization
requestHeaders:
session-id: "authorization-error"
response:
statusCode: 500
content: |
{
"redirect_uri": "http://example.net",
"oauth_error": {
"error_description": "gateway",
"error": "server_error"
}
}
### 'session-400' journey ###
- method: POST
path: /session
requestBody:
jsonPath: $.client_id
value: "session-400"
response:
statusCode: 400
template: true
content: |
{}
### 'session-500' journey ###
- method: POST
path: /session
requestBody:
jsonPath: $.client_id
value: "session-500"
response:
statusCode: 500
template: true
content: |
{}
- method: POST
path: /session
requestBody:
jsonPath: $.client_id
value: "abandon"
response:
statusCode: 201
template: true
content: |
{
"session_id": "abandon",
"state": "sT@t3",
"redirect_uri": "http://example.net"
}
- method: POST
path: /answer
requestHeaders:
session-id: "abandon"
response:
scriptFile: scripts/post-answer.groovy
# Default journey that will get questions from the question store matching the initial client_id value as long as that
# value starts with "questions-"
- method: POST
path: /session
# Capture the client_id value here so we can use it in the response
capture:
journey:
jsonPath: $.client_id
store: request
requestBody:
jsonPath: $.client_id
value: "questions-.+" # match anything starting with "questions-"
operator: Matches
response:
statusCode: 201
template: true
# Set the session id to a unique value based on the client_id. The random element means that we can run tests
# multiple times without clashes in the stores.
content: |
{
"session_id": "${stores.request.journey}-SEPARATOR-${random.uuid()}",
"state": "sT@t3",
"redirect_uri": "http://example.net"
}
- method: POST
path: /fetchquestions
requestHeaders:
session-id:
value: "questions-.+-SEPARATOR-.+" # Match our session_id pattern
operator: Matches
response:
statusCode: 200
- method: GET
path: /question
requestHeaders:
session-id:
value: "questions-.+-SEPARATOR-.+" # Match our session_id pattern
operator: Matches
response:
scriptFile: scripts/get-question.groovy
- method: POST
path: /answer
requestHeaders:
session-id:
value: "questions-.+-SEPARATOR-.+" # Match our session_id pattern
operator: Matches
response:
scriptFile: scripts/post-answer.groovy
- method: GET
path: /authorization
requestHeaders:
session-id:
value: "questions-.+-SEPARATOR-.+" # Match our session_id pattern
operator: Matches
steps:
# short-circuit when it's the 'abandon' journey
- type: script
lang: groovy
code: |
if (context.request.headers['session-id'] ==~ /questions-abandon.+/) {
def deniedResponse = [
redirect_uri: "http://example.net",
oauth_error: [ error_description: "access-denied", error: "access_denied" ]
]
def serializer = new groovy.json.JsonOutput()
respond().withStatusCode(500).withContent(serializer.toJson(deniedResponse))
}
response:
template: true
statusCode: 200
content: |
{
"authorizationCode": {
"value":"auth-code-${random.uuid()}"
},
"state":"sT@t3",
"redirect_uri":"http://example.net"
}