Skip to content

Commit d42e023

Browse files
committed
Write test for #37 Service accepts excess slashes (still)
1 parent 6d18011 commit d42e023

File tree

2 files changed

+82
-1
lines changed

2 files changed

+82
-1
lines changed

src/bun/features/assetService.feature

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,62 @@ Scenario: Should return 404 when excess slashes
154154
| property | value |
155155
| status | 404 |
156156

157+
Scenario: Should return 404 when excess slashes (2)
158+
Given enonic is running in production mode
159+
# Given loglevel is set to "debug"
160+
Given the following resources:
161+
| path | exist |
162+
| /assets//icons//favicons//apple-touch-icon-120x120.png | false |
163+
Given the following request:
164+
| property | value |
165+
| branch | draft |
166+
| contextPath | /admin/tool/_/service/com.enonic.xp.app.standardidprovider/asset |
167+
| host | localhost |
168+
| method | GET |
169+
| mode | admin |
170+
| path | /admin/tool/_/service/com.enonic.xp.app.standardidprovider/asset/1727786440404/icons/favicons/apple-touch-icon-120x120.png |
171+
| port | 8080 |
172+
| rawPath | /admin/tool/_/service/com.enonic.xp.app.standardidprovider/asset/1727786440404//icons//favicons//apple-touch-icon-120x120.png |
173+
| remoteAddress | 127.0.0.1 |
174+
| repositoryId | com.enonic.cms.default |
175+
| scheme | http |
176+
| url | http://localhost:8080/admin/tool/_/service/com.enonic.xp.app.standardidprovider/asset/1727786440404/icons/favicons/apple-touch-icon-120x120.png |
177+
| webSocket | false |
178+
Given the following request headers:
179+
| header | value |
180+
| Accept | text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7 |
181+
| Accept-Encoding | gzip, deflate, br, zstd |
182+
| Accept-Language | en-GB,en-US;q=0.9,en;q=0.8,no;q=0.7 |
183+
| Cache-Control | no-cache |
184+
| Connection | keep-alive |
185+
| Cookie | app.browse.RecentItemsList=base%3Afolder%7Cportal%3Asite; JSESSIONID=1o50615fgjqlt1wsbsvcubu00m2 |
186+
| Host | localhost:8080 |
187+
| Pragma | no-cache |
188+
| sec-ch-ua | "Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128" |
189+
| sec-ch-ua-mobile | ?0 |
190+
| sec-ch-ua-platform | "macOS" |
191+
| Sec-Fetch-Dest | document |
192+
| Sec-Fetch-Mode | navigate |
193+
| Sec-Fetch-Site | none |
194+
| Sec-Fetch-User | ?1 |
195+
| Upgrade-Insecure-Requests | 1 |
196+
| User-Agent | Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 |
197+
Given the following request cookies:
198+
| name | value |
199+
| app.browse.RecentItemsList | base%3Afolder%7Cportal%3Asite |
200+
| JSESSIONID | 1o50615fgjqlt1wsbsvcubu00m2 |
201+
Given the following request params:
202+
| param | value |
203+
Given the following request path params:
204+
| param | value |
205+
| path | /1727786440404//icons//favicons//apple-touch-icon-120x120.png |
206+
# Then log info the request
207+
When the request is sent
208+
# Then log info the response
209+
Then the response should have the following properties:
210+
| property | value |
211+
| status | 404 |
212+
157213
Scenario: prefers brotli even though it comes last and have lowest qvalue weight
158214
Given enonic is running in production mode
159215
Given the following resources:

src/bun/features/assetService.feature.test.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ export const steps: StepDefinitions = ({given, and, when, then}) => {
7575
// headers: {},
7676
};
7777
table.forEach(({property, value}) => {
78-
request[property] = value;
78+
if (property === 'webSocket') {
79+
request[property] = value === 'true';
80+
} else {
81+
request[property] = value;
82+
}
7983
});
8084
});
8185

@@ -86,13 +90,34 @@ export const steps: StepDefinitions = ({given, and, when, then}) => {
8690
request.headers[header] = value;
8791
});
8892

93+
given('the following request cookies:', (table) => {
94+
request.cookies = {};
95+
table.forEach(({name, value}) => {
96+
request.cookies[name] = value;
97+
});
98+
});
99+
89100
and('the following request headers:', (table) => {
90101
request.headers = {};
91102
table.forEach(({header, value}) => {
92103
request.headers[header] = value;
93104
});
94105
});
95106

107+
given('the following request params:', (table) => {
108+
request.params = {};
109+
table.forEach(({param, value}) => {
110+
request.params[param] = value;
111+
});
112+
});
113+
114+
given('the following request path params:', (table) => {
115+
request.pathParams = {};
116+
table.forEach(({param, value}) => {
117+
request.pathParams[param] = value;
118+
});
119+
});
120+
96121
then('the resources are info logged', () => {
97122
testLogger.info('resources:%s', globalThis._resources);
98123
});

0 commit comments

Comments
 (0)