webship-js 2.0.10 → 2.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/ISSUE_TEMPLATE/issue.md +37 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +24 -0
- package/.github/workflows/github-actions.yml +56 -4
- package/CLAUDE.md +5 -2
- package/README.md +13 -1
- package/bin/generate-reports.js +51 -7
- package/bin/init-webship.js +85 -17
- package/cucumber.js +29 -1
- package/docs/00-quick-start.md +30 -7
- package/docs/02-bbr-smart-waits.md +6 -0
- package/docs/04-step-reference.md +2 -2
- package/docs/11-debugging.md +21 -0
- package/docs/12-ai-agent-guide.md +3 -1
- package/docs/13-faq.md +3 -0
- package/docs/15-tag-conventions.md +4 -1
- package/docs/16-ci-cd.md +29 -13
- package/docs/global-settings.md +2 -2
- package/docs/install-webship-js/ddev-webship-js.md +3 -0
- package/docs/install-webship-js.md +14 -2
- package/examples/a11y-legacy-widget.html +34 -0
- package/examples/auth-state.html +42 -0
- package/examples/clock.html +33 -0
- package/examples/downloads/webship-archive.zip +0 -0
- package/examples/downloads/webship-notes.txt +4 -0
- package/examples/downloads/webship-report.csv +4 -0
- package/examples/downloads.html +16 -0
- package/examples/element-viewport.html +42 -0
- package/examples/field-types.html +98 -0
- package/examples/iframe-newsletter.html +29 -0
- package/examples/iframe-order.html +26 -0
- package/examples/iframe.html +21 -0
- package/examples/javascript-errors.html +35 -0
- package/examples/links.html +1 -0
- package/examples/metatags.html +18 -0
- package/examples/mouse-and-pointer.html +83 -0
- package/examples/native-dialogs.html +8 -0
- package/examples/network.html +83 -0
- package/examples/scroll-horizontal.html +50 -0
- package/examples/selectors-position.html +29 -0
- package/examples/storage.html +57 -0
- package/examples/viewport-size.html +24 -0
- package/examples/wait-conditions.html +69 -0
- package/examples/web-first.html +99 -0
- package/package.json +9 -2
- package/tests/assets/catalog.xml +19 -0
- package/tests/assets/feed-namespaced.xml +13 -0
- package/tests/assets/sitemap.xml +14 -0
- package/tests/assets/webship-site-expected.yaml +21 -0
- package/tests/assets/webship-site.schema.json +46 -0
- package/tests/assets/webship-site.yaml +21 -0
- package/tests/check-examples.js +235 -0
- package/tests/check-must-fail.js +84 -0
- package/tests/check-paths.js +82 -0
- package/tests/check-report.js +119 -0
- package/tests/check-scaffold.js +211 -0
- package/tests/features/a11y.feature +18 -0
- package/tests/features/auth-state.feature +32 -0
- package/tests/features/clock.feature +27 -0
- package/tests/features/cookie.feature +9 -0
- package/tests/features/dialog.feature +27 -0
- package/tests/features/element.feature +47 -0
- package/tests/features/field.feature +104 -0
- package/tests/features/file-download.feature +64 -0
- package/tests/features/iframe.feature +83 -0
- package/tests/features/javascript.feature +47 -0
- package/tests/features/link.feature +11 -0
- package/tests/features/metatag.feature +38 -0
- package/tests/features/mouse-and-pointer.feature +86 -0
- package/tests/features/network-mocking.feature +80 -0
- package/tests/features/responsive.feature +27 -0
- package/tests/features/scroll-horizontal.feature +55 -0
- package/tests/features/selectors-position.feature +41 -0
- package/tests/features/storage.feature +98 -0
- package/tests/features/test--then--i-see-locator.feature +13 -0
- package/tests/features/test--then--i-should--see-text-in-element.feature +9 -1
- package/tests/features/test--then--the-field-should-contain-value.feature +8 -0
- package/tests/features/video.feature +1 -0
- package/tests/features/wait.feature +89 -0
- package/tests/features/web-first.feature +100 -0
- package/tests/features/xml.feature +96 -0
- package/tests/features/yaml.feature +75 -0
- package/tests/must-fail/assertions.feature +96 -0
- package/tests/must-fail/waits.feature +51 -0
- package/tests/reports/README.md +2 -2
- package/tests/step-definitions/a11y.steps.js +12 -8
- package/tests/step-definitions/assertion.steps.js +235 -61
- package/tests/step-definitions/dialog.steps.js +2 -2
- package/tests/step-definitions/element.steps.js +3 -1
- package/tests/step-definitions/field.steps.js +152 -22
- package/tests/step-definitions/file-download.steps.js +74 -10
- package/tests/step-definitions/screenshot.steps.js +1 -1
- package/tests/step-definitions/selectors.steps.js +9 -3
- package/tests/step-definitions/storage.steps.js +3 -3
- package/tests/step-definitions/wait.steps.js +129 -39
- package/tests/step-definitions/webship.js +144 -3
- package/tests/step-definitions/xml.steps.js +76 -14
- package/tests/step-definitions/yaml.steps.js +46 -27
- package/.scratch/commit.txt +0 -14
- package/.scratch/docs.py +0 -42
- package/.scratch/echo-server.js +0 -8
- package/.scratch/echo.js +0 -35
- package/.scratch/echo.pid +0 -1
- package/.scratch/features/cookies.feature +0 -22
- package/.scratch/http.pid +0 -1
- package/.scratch/https.pid +0 -1
- package/.scratch/issue.md +0 -49
- package/.scratch/one.js +0 -2
- package/.scratch/one.json +0 -280
- package/.scratch/patch.py +0 -163
- package/.scratch/pr.md +0 -30
|
@@ -31,10 +31,30 @@ function requireYaml() {
|
|
|
31
31
|
|
|
32
32
|
function ensureLoaded(world) {
|
|
33
33
|
requireYaml();
|
|
34
|
+
if (world._yamlParseError) {
|
|
35
|
+
throw friendly(`The response is not valid YAML: ${world._yamlParseError.message}`);
|
|
36
|
+
}
|
|
34
37
|
if (world._yaml === undefined) throw friendly('No YAML response has been set.');
|
|
35
38
|
return world._yaml;
|
|
36
39
|
}
|
|
37
40
|
|
|
41
|
+
// Keep the raw content even when it does not parse, so that the two format
|
|
42
|
+
// steps ("should be" / "should not be in YAML format") can judge it.
|
|
43
|
+
function setYamlResponse(world, content) {
|
|
44
|
+
requireYaml();
|
|
45
|
+
world._rawYamlResponse = content;
|
|
46
|
+
world._yamlDocIndex = 0;
|
|
47
|
+
world._yamlParseError = null;
|
|
48
|
+
try {
|
|
49
|
+
world._yamlDocs = YAML.loadAll(content);
|
|
50
|
+
world._yaml = world._yamlDocs[0];
|
|
51
|
+
} catch (e) {
|
|
52
|
+
world._yamlDocs = [];
|
|
53
|
+
world._yaml = undefined;
|
|
54
|
+
world._yamlParseError = e;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
38
58
|
// Active document index for multi-document streams.
|
|
39
59
|
function activeIndex(world) { return world._yamlDocIndex || 0; }
|
|
40
60
|
function activeDoc(world) {
|
|
@@ -118,11 +138,7 @@ function typeOfNode(node) {
|
|
|
118
138
|
Given('the YAML response content from the file {string}', async function (filename) {
|
|
119
139
|
requireYaml();
|
|
120
140
|
const p = path.isAbsolute(filename) ? filename : path.join(this.assetsFolder || './tests/assets', filename);
|
|
121
|
-
|
|
122
|
-
this._rawYamlResponse = content;
|
|
123
|
-
this._yamlDocs = YAML.loadAll(content);
|
|
124
|
-
this._yaml = this._yamlDocs[0];
|
|
125
|
-
this._yamlDocIndex = 0;
|
|
141
|
+
setYamlResponse(this, fs.readFileSync(p, 'utf-8'));
|
|
126
142
|
});
|
|
127
143
|
|
|
128
144
|
/**
|
|
@@ -162,11 +178,7 @@ Given('the YAML response content from the file {string}', async function (filena
|
|
|
162
178
|
*
|
|
163
179
|
*/
|
|
164
180
|
Given('the YAML response content is the following:', async function (docString) {
|
|
165
|
-
|
|
166
|
-
this._rawYamlResponse = docString;
|
|
167
|
-
this._yamlDocs = YAML.loadAll(docString);
|
|
168
|
-
this._yaml = this._yamlDocs[0];
|
|
169
|
-
this._yamlDocIndex = 0;
|
|
181
|
+
setYamlResponse(this, docString);
|
|
170
182
|
});
|
|
171
183
|
|
|
172
184
|
/**
|
|
@@ -236,12 +248,13 @@ Then('the response should be in YAML format', async function () {
|
|
|
236
248
|
});
|
|
237
249
|
|
|
238
250
|
/**
|
|
239
|
-
* Assert the loaded response is NOT valid YAML.
|
|
251
|
+
* Assert the loaded response is NOT valid YAML. Fails when the content
|
|
252
|
+
* parses: a line of plain text or a JSON document is valid YAML too.
|
|
240
253
|
*
|
|
241
254
|
* Example #1: Then the response should not be in YAML format
|
|
242
255
|
* Example #2: Given the YAML response content is the following:
|
|
243
256
|
* """
|
|
244
|
-
*
|
|
257
|
+
* items: [one, two
|
|
245
258
|
* """
|
|
246
259
|
* Then the response should not be in YAML format
|
|
247
260
|
* Example #3: And the response should not be in YAML format
|
|
@@ -255,9 +268,11 @@ Then('the response should be in YAML format', async function () {
|
|
|
255
268
|
*
|
|
256
269
|
*/
|
|
257
270
|
Then('the response should not be in YAML format', async function () {
|
|
258
|
-
|
|
271
|
+
requireYaml();
|
|
272
|
+
assert.ok(this._rawYamlResponse, 'No YAML response content set.');
|
|
259
273
|
try { YAML.loadAll(this._rawYamlResponse); }
|
|
260
274
|
catch (e) { return; /* expected */ }
|
|
275
|
+
assert.fail('Response is valid YAML.');
|
|
261
276
|
});
|
|
262
277
|
|
|
263
278
|
/**
|
|
@@ -853,6 +868,17 @@ Then('the YAML should equal the file {string} ignoring keys {string}', function
|
|
|
853
868
|
// Namespace + debug
|
|
854
869
|
// ---------------------------------------------------------------------------
|
|
855
870
|
|
|
871
|
+
// One answer for both namespace steps: a top-level value equal to the
|
|
872
|
+
// namespace, or the namespace anywhere in the raw text.
|
|
873
|
+
function usesNamespace(world, ns) {
|
|
874
|
+
const doc = activeDoc(world);
|
|
875
|
+
if (doc && typeof doc === 'object') {
|
|
876
|
+
const values = Object.values(doc).map((v) => (v == null ? '' : String(v)));
|
|
877
|
+
if (values.includes(ns)) return true;
|
|
878
|
+
}
|
|
879
|
+
return (world._rawYamlResponse || '').indexOf(ns) !== -1;
|
|
880
|
+
}
|
|
881
|
+
|
|
856
882
|
/**
|
|
857
883
|
* Assert the YAML document declares a namespace value (mirrors xml.steps.js).
|
|
858
884
|
* Checks top-level scalar values and falls back to a raw-text scan.
|
|
@@ -865,16 +891,14 @@ Then('the YAML should equal the file {string} ignoring keys {string}', function
|
|
|
865
891
|
*
|
|
866
892
|
*/
|
|
867
893
|
Then('the YAML should use the namespace {string}', function (ns) {
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
const values = Object.values(doc).map((v) => (v == null ? '' : String(v)));
|
|
871
|
-
if (values.includes(ns)) return;
|
|
872
|
-
}
|
|
873
|
-
assert.ok((this._rawYamlResponse || '').indexOf(ns) !== -1, `Namespace "${ns}" not declared.`);
|
|
894
|
+
ensureLoaded(this);
|
|
895
|
+
assert.ok(usesNamespace(this, ns), `Namespace "${ns}" not declared.`);
|
|
874
896
|
});
|
|
875
897
|
|
|
876
898
|
/**
|
|
877
|
-
* Assert the YAML document does NOT declare a namespace value
|
|
899
|
+
* Assert the YAML document does NOT declare a namespace value: the exact
|
|
900
|
+
* opposite of the step above (no top-level value equal to it, and the raw
|
|
901
|
+
* text does not carry it).
|
|
878
902
|
*
|
|
879
903
|
* Example #1: Then the YAML should not use the namespace "v0"
|
|
880
904
|
* Example #2: Then the YAML should not use the namespace "internal/v1"
|
|
@@ -884,13 +908,8 @@ Then('the YAML should use the namespace {string}', function (ns) {
|
|
|
884
908
|
*
|
|
885
909
|
*/
|
|
886
910
|
Then('the YAML should not use the namespace {string}', function (ns) {
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
const values = Object.values(doc).map((v) => (v == null ? '' : String(v)));
|
|
890
|
-
assert.ok(!values.includes(ns), `Namespace "${ns}" should not be declared.`);
|
|
891
|
-
return;
|
|
892
|
-
}
|
|
893
|
-
assert.ok((this._rawYamlResponse || '').indexOf(ns) === -1, `Namespace "${ns}" should not be declared.`);
|
|
911
|
+
ensureLoaded(this);
|
|
912
|
+
assert.ok(!usesNamespace(this, ns), `Namespace "${ns}" should not be declared.`);
|
|
894
913
|
});
|
|
895
914
|
|
|
896
915
|
/**
|
package/.scratch/commit.txt
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
Fix: send the REST and API requests with the HTTPS setting of the browser (#333)
|
|
2
|
-
|
|
3
|
-
The REST and API request steps sent their request from Node with axios,
|
|
4
|
-
outside the browser, so on HTTPS with a self-signed or locally issued
|
|
5
|
-
certificate they failed with "self-signed certificate" although the
|
|
6
|
-
browser itself opened the site.
|
|
7
|
-
|
|
8
|
-
Both now use Playwright's request API. The REST steps go through the
|
|
9
|
-
browser context and follow its cookies, credentials and HTTPS setting.
|
|
10
|
-
The API steps keep their own base URL, authentication and headers: they
|
|
11
|
-
use a request context of their own, with the HTTPS setting of the browser
|
|
12
|
-
context and no cookie of the browser.
|
|
13
|
-
|
|
14
|
-
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
package/.scratch/docs.py
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
p='docs/09-api-testing.md'
|
|
2
|
-
s=open(p).read()
|
|
3
|
-
old="Webship-js scenarios can talk to an HTTP API directly without leaving the cucumber-js runtime. The browser context's cookie jar is shared, so a UI login can be followed by REST-level assertions in the same scenario.\n"
|
|
4
|
-
new="""Webship-js scenarios can talk to an HTTP API directly without leaving the cucumber-js runtime. Every request is sent with Playwright's request API and follows the HTTPS setting of the browser context (`ignoreHTTPSErrors` in `playwright.config.ts`), so a site served with a self-signed or locally issued certificate answers these steps the same way it answers the browser.
|
|
5
|
-
|
|
6
|
-
There are two families of steps, and they differ in one point:
|
|
7
|
-
|
|
8
|
-
| Steps | Sent | Cookies of the browser |
|
|
9
|
-
| --- | --- | --- |
|
|
10
|
-
| `I send a REST "<method>" request to "<url>"` (`rest.steps.js`) | through the browser context | shared: a UI login can be followed by REST-level assertions in the same scenario |
|
|
11
|
-
| `I send a <METHOD> request to "<endpoint>"` (`api.steps.js`) | outside the browser session | not sent, and none comes back into the browser: the request carries only the base URL, the authentication and the headers the scenario set |
|
|
12
|
-
"""
|
|
13
|
-
assert old in s; s=s.replace(old,new)
|
|
14
|
-
old="A parallel short-form lives in `rest.steps.js` for quick smoke tests:\n"
|
|
15
|
-
new="A parallel short-form lives in `rest.steps.js` for quick smoke tests. A path is joined to the launch URL, an absolute URL is requested as written, and the request goes through the browser context: it shares the session cookies and the HTTPS setting of the page.\n"
|
|
16
|
-
assert old in s; s=s.replace(old,new)
|
|
17
|
-
open(p,'w').write(s)
|
|
18
|
-
p='docs/api-step-definitions.md'
|
|
19
|
-
s=open(p).read()
|
|
20
|
-
old="""webship-js ships native HTTP / REST API step definitions powered by
|
|
21
|
-
Playwright's request fixture and `axios`. They share the browser
|
|
22
|
-
context's cookie jar so the same scenario can mix UI actions and
|
|
23
|
-
direct API calls.
|
|
24
|
-
"""
|
|
25
|
-
new="""webship-js ships native HTTP / REST API step definitions powered by
|
|
26
|
-
Playwright's request API, so the same scenario can mix UI actions and
|
|
27
|
-
direct API calls.
|
|
28
|
-
|
|
29
|
-
The API steps on this page send their requests outside the browser
|
|
30
|
-
session: a request carries the base URL, the authentication and the
|
|
31
|
-
headers the scenario set, and no cookie of the browser. They follow the
|
|
32
|
-
HTTPS setting of the browser context (`ignoreHTTPSErrors` in
|
|
33
|
-
`playwright.config.ts`), so an API served with a self-signed or locally
|
|
34
|
-
issued certificate answers them the same way it answers the browser.
|
|
35
|
-
|
|
36
|
-
To send a request with the cookies of the browser session, after a UI
|
|
37
|
-
login for example, use the short-form REST steps
|
|
38
|
-
(`When I send a REST "GET" request to "/api/me"`), which go through the
|
|
39
|
-
browser context.
|
|
40
|
-
"""
|
|
41
|
-
assert old in s; s=s.replace(old,new)
|
|
42
|
-
open(p,'w').write(s)
|
package/.scratch/echo-server.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
const http = require('http');
|
|
2
|
-
http.createServer((req, res) => {
|
|
3
|
-
let b = ''; req.on('data', c => b += c); req.on('end', () => {
|
|
4
|
-
res.setHeader('content-type', 'application/json');
|
|
5
|
-
res.setHeader('set-cookie', 'from_api=1; Path=/');
|
|
6
|
-
res.end(JSON.stringify({ method: req.method, cookie: req.headers.cookie || 'none', auth: req.headers.authorization || 'none', type: req.headers['content-type'] || 'none', body: b }));
|
|
7
|
-
});
|
|
8
|
-
}).listen(8990);
|
package/.scratch/echo.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
const http = require('http');
|
|
2
|
-
const axios = require('axios');
|
|
3
|
-
const { request } = require('playwright');
|
|
4
|
-
const srv = http.createServer((req, res) => {
|
|
5
|
-
let b = ''; req.on('data', c => b += c); req.on('end', () => {
|
|
6
|
-
res.setHeader('content-type', 'application/json');
|
|
7
|
-
res.end(JSON.stringify({ m: req.method, h: req.headers, b }));
|
|
8
|
-
});
|
|
9
|
-
}).listen(0, async () => {
|
|
10
|
-
const u = `http://localhost:${srv.address().port}/x`;
|
|
11
|
-
const cases = [
|
|
12
|
-
['GET nodata', { method: 'GET', url: u, headers: {}, data: null }],
|
|
13
|
-
['GET undefined', { method: 'GET', url: u, headers: {} }],
|
|
14
|
-
['GET obj', { method: 'GET', url: u, headers: {}, data: { a: 1 } }],
|
|
15
|
-
['POST null', { method: 'POST', url: u, headers: {}, data: null }],
|
|
16
|
-
['POST obj', { method: 'POST', url: u, headers: {}, data: { a: 1 } }],
|
|
17
|
-
['POST str json', { method: 'POST', url: u, headers: {}, data: '{"a": 1}' }],
|
|
18
|
-
['POST str json ct', { method: 'POST', url: u, headers: { 'Content-Type': 'application/json' }, data: '{"a":1}' }],
|
|
19
|
-
['POST str form', { method: 'POST', url: u, headers: {}, data: 'a=1&b=2' }],
|
|
20
|
-
['POST str ct json nonjson', { method: 'POST', url: u, headers: { 'Content-Type': 'application/json' }, data: JSON.stringify({a:'1'}) }],
|
|
21
|
-
['DELETE', { method: 'DELETE', url: u, headers: {} }],
|
|
22
|
-
['post lowercase', { method: 'post', url: u, headers: {}, data: 'x' }],
|
|
23
|
-
];
|
|
24
|
-
const ctx = await request.newContext();
|
|
25
|
-
for (const [n, c] of cases) {
|
|
26
|
-
const r = await axios({ ...c, validateStatus: () => true });
|
|
27
|
-
const d = r.data; delete d.h.host; delete d.h.connection;
|
|
28
|
-
console.log('AX', n, JSON.stringify(d));
|
|
29
|
-
const o = { method: c.method, headers: c.headers };
|
|
30
|
-
if (c.data !== undefined && c.data !== null) o.data = c.data;
|
|
31
|
-
const p = await ctx.fetch(u, o); const pj = await p.json(); delete pj.h.host; delete pj.h.connection;
|
|
32
|
-
console.log('PW', n, JSON.stringify(pj));
|
|
33
|
-
}
|
|
34
|
-
await ctx.dispose(); srv.close();
|
|
35
|
-
});
|
package/.scratch/echo.pid
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
2359762
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
Feature: cookie check (not committed)
|
|
2
|
-
Scenario: REST shares the browser cookies, API does not
|
|
3
|
-
Given I am on "/about-us.html"
|
|
4
|
-
And the cookie "session_id" is set to "abc123"
|
|
5
|
-
Given the API base URL is "http://localhost:8990"
|
|
6
|
-
And I am authenticating as "tester" with "secret" password
|
|
7
|
-
When I send a POST request to "/echo" with body:
|
|
8
|
-
"""
|
|
9
|
-
{"a": 1}
|
|
10
|
-
"""
|
|
11
|
-
Then the JSON response should have "cookie" equal to "none"
|
|
12
|
-
And the JSON response should have "auth" equal to "Basic dGVzdGVyOnNlY3JldA=="
|
|
13
|
-
And the JSON response should have "type" equal to "application/json"
|
|
14
|
-
And a cookie with the name "from_api" should not exist
|
|
15
|
-
When I send a REST "POST" request to "http://localhost:8990/echo" with body:
|
|
16
|
-
"""
|
|
17
|
-
a=1&b=2
|
|
18
|
-
"""
|
|
19
|
-
Then the REST response should contain "session_id=abc123"
|
|
20
|
-
And the REST response should contain "application/x-www-form-urlencoded"
|
|
21
|
-
And the REST response should contain "a=1&b=2"
|
|
22
|
-
And a cookie with the name "from_api" should exist
|
package/.scratch/http.pid
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
2324561
|
package/.scratch/https.pid
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
2324559
|
package/.scratch/issue.md
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
### Problem/Motivation
|
|
2
|
-
|
|
3
|
-
`When I send a REST "<method>" request to "<url>"` (`tests/step-definitions/rest.steps.js`) and the API request steps `When I send a <METHOD> request to "<endpoint>"` with their `with body:`, `with values:` and `with form data:` forms (`tests/step-definitions/api.steps.js`) send their request from Node with `axios`, outside the browser. Node does not trust a self-signed or locally issued certificate, so on a site served over HTTPS with one the REST step fails with:
|
|
4
|
-
|
|
5
|
-
```
|
|
6
|
-
Error: self-signed certificate
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
and the API steps fail with:
|
|
10
|
-
|
|
11
|
-
```
|
|
12
|
-
GET request failed: self-signed certificate
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
(`unable to verify the first certificate` when the certificate comes from a local authority.) The browser itself opens the same site, because the browser context sets `ignoreHTTPSErrors`. It is the same weakness as #330, in the remaining steps that still send a request from Node.
|
|
16
|
-
|
|
17
|
-
#### Steps to reproduce
|
|
18
|
-
|
|
19
|
-
1. Serve `examples/` over HTTPS with a self-signed certificate: `npx http-server examples -p 8443 -S -C cert.pem -K key.pem`.
|
|
20
|
-
2. Run the suite with `LAUNCH_URL=https://localhost:8443`.
|
|
21
|
-
3. `When I send a REST "GET" request to "/example-api.json"` (`tests/features/absolute-url.feature:41`) fails with `Error: self-signed certificate`.
|
|
22
|
-
4. `Given the API base URL is "/"`, `When I send a GET request to "/example-api.json"` fails with `GET request failed: self-signed certificate`.
|
|
23
|
-
|
|
24
|
-
### Proposed resolution
|
|
25
|
-
|
|
26
|
-
Send these requests with Playwright's request API so they follow the HTTPS setting of the browser context: the REST steps through the browser context itself, the API steps from a request context of their own that carries no cookie of the browser.
|
|
27
|
-
|
|
28
|
-
AI-Generated: Yes
|
|
29
|
-
|
|
30
|
-
### Checkpoints:
|
|
31
|
-
- [x] File an issue
|
|
32
|
-
- [ ] Addition/Change/Update/Fix
|
|
33
|
-
- [ ] Testing to ensure no regression
|
|
34
|
-
- [ ] Automated unit testing coverage
|
|
35
|
-
- [ ] Automated functional testing coverage
|
|
36
|
-
- [ ] UX/UI designer responsibilities
|
|
37
|
-
- [ ] Readability
|
|
38
|
-
- [ ] Accessibility
|
|
39
|
-
- [ ] Performance
|
|
40
|
-
- [ ] Security
|
|
41
|
-
- [ ] Developer Documentation
|
|
42
|
-
- [ ] User Guide Documentation
|
|
43
|
-
- [ ] Reviewed by human
|
|
44
|
-
- [ ] Code review by maintainers
|
|
45
|
-
- [ ] Full testing and approval
|
|
46
|
-
- [ ] Credit contributors
|
|
47
|
-
- [ ] Review with the product owner
|
|
48
|
-
- [ ] Release notes snippet
|
|
49
|
-
- [ ] Release
|
package/.scratch/one.js
DELETED
package/.scratch/one.json
DELETED
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"description": "",
|
|
4
|
-
"elements": [
|
|
5
|
-
{
|
|
6
|
-
"description": "",
|
|
7
|
-
"id": "cookie-check-(not-committed);rest-shares-the-browser-cookies,-api-does-not",
|
|
8
|
-
"keyword": "Scenario",
|
|
9
|
-
"line": 2,
|
|
10
|
-
"name": "REST shares the browser cookies, API does not",
|
|
11
|
-
"steps": [
|
|
12
|
-
{
|
|
13
|
-
"keyword": "Before",
|
|
14
|
-
"hidden": true,
|
|
15
|
-
"result": {
|
|
16
|
-
"status": "passed",
|
|
17
|
-
"duration": 59045699
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"keyword": "Before",
|
|
22
|
-
"hidden": true,
|
|
23
|
-
"result": {
|
|
24
|
-
"status": "passed",
|
|
25
|
-
"duration": 146611
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"keyword": "Before",
|
|
30
|
-
"hidden": true,
|
|
31
|
-
"result": {
|
|
32
|
-
"status": "passed",
|
|
33
|
-
"duration": 429690
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
"keyword": "Before",
|
|
38
|
-
"hidden": true,
|
|
39
|
-
"result": {
|
|
40
|
-
"status": "passed",
|
|
41
|
-
"duration": 358450
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
"keyword": "Before",
|
|
46
|
-
"hidden": true,
|
|
47
|
-
"result": {
|
|
48
|
-
"status": "passed",
|
|
49
|
-
"duration": 56777
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
"keyword": "Before",
|
|
54
|
-
"hidden": true,
|
|
55
|
-
"result": {
|
|
56
|
-
"status": "passed",
|
|
57
|
-
"duration": 106737
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
"arguments": [],
|
|
62
|
-
"keyword": "Given ",
|
|
63
|
-
"line": 3,
|
|
64
|
-
"name": "I am on \"/about-us.html\"",
|
|
65
|
-
"match": {
|
|
66
|
-
"location": "tests/step-definitions/navigation.steps.js:64"
|
|
67
|
-
},
|
|
68
|
-
"result": {
|
|
69
|
-
"status": "passed",
|
|
70
|
-
"duration": 520204689
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
"arguments": [],
|
|
75
|
-
"keyword": "And ",
|
|
76
|
-
"line": 4,
|
|
77
|
-
"name": "the cookie \"session_id\" is set to \"abc123\"",
|
|
78
|
-
"match": {
|
|
79
|
-
"location": "tests/step-definitions/storage.steps.js:31"
|
|
80
|
-
},
|
|
81
|
-
"result": {
|
|
82
|
-
"status": "passed",
|
|
83
|
-
"duration": 2178232
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
"arguments": [],
|
|
88
|
-
"keyword": "Given ",
|
|
89
|
-
"line": 5,
|
|
90
|
-
"name": "the API base URL is \"http://localhost:8990\"",
|
|
91
|
-
"match": {
|
|
92
|
-
"location": "tests/step-definitions/api.steps.js:101"
|
|
93
|
-
},
|
|
94
|
-
"result": {
|
|
95
|
-
"status": "passed",
|
|
96
|
-
"duration": 449720
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
"arguments": [],
|
|
101
|
-
"keyword": "And ",
|
|
102
|
-
"line": 6,
|
|
103
|
-
"name": "I am authenticating as \"tester\" with \"secret\" password",
|
|
104
|
-
"match": {
|
|
105
|
-
"location": "tests/step-definitions/api.steps.js:66"
|
|
106
|
-
},
|
|
107
|
-
"result": {
|
|
108
|
-
"status": "passed",
|
|
109
|
-
"duration": 356252
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
"arguments": [
|
|
114
|
-
{
|
|
115
|
-
"content": "{\"a\": 1}",
|
|
116
|
-
"line": 8
|
|
117
|
-
}
|
|
118
|
-
],
|
|
119
|
-
"keyword": "When ",
|
|
120
|
-
"line": 7,
|
|
121
|
-
"name": "I send a POST request to \"/echo\" with body:",
|
|
122
|
-
"match": {
|
|
123
|
-
"location": "tests/step-definitions/api.steps.js:314"
|
|
124
|
-
},
|
|
125
|
-
"result": {
|
|
126
|
-
"status": "passed",
|
|
127
|
-
"duration": 15836827
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
"arguments": [],
|
|
132
|
-
"keyword": "Then ",
|
|
133
|
-
"line": 11,
|
|
134
|
-
"name": "the JSON response should have \"cookie\" equal to \"none\"",
|
|
135
|
-
"match": {
|
|
136
|
-
"location": "tests/step-definitions/api.steps.js:548"
|
|
137
|
-
},
|
|
138
|
-
"result": {
|
|
139
|
-
"status": "passed",
|
|
140
|
-
"duration": 230198
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
"arguments": [],
|
|
145
|
-
"keyword": "And ",
|
|
146
|
-
"line": 12,
|
|
147
|
-
"name": "the JSON response should have \"auth\" equal to \"Basic dGVzdGVyOnNlY3JldA==\"",
|
|
148
|
-
"match": {
|
|
149
|
-
"location": "tests/step-definitions/api.steps.js:548"
|
|
150
|
-
},
|
|
151
|
-
"result": {
|
|
152
|
-
"status": "passed",
|
|
153
|
-
"duration": 134050
|
|
154
|
-
}
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
"arguments": [],
|
|
158
|
-
"keyword": "And ",
|
|
159
|
-
"line": 13,
|
|
160
|
-
"name": "the JSON response should have \"type\" equal to \"application/json\"",
|
|
161
|
-
"match": {
|
|
162
|
-
"location": "tests/step-definitions/api.steps.js:548"
|
|
163
|
-
},
|
|
164
|
-
"result": {
|
|
165
|
-
"status": "passed",
|
|
166
|
-
"duration": 146486
|
|
167
|
-
}
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
"arguments": [],
|
|
171
|
-
"keyword": "And ",
|
|
172
|
-
"line": 14,
|
|
173
|
-
"name": "a cookie with the name \"from_api\" should not exist",
|
|
174
|
-
"match": {
|
|
175
|
-
"location": "tests/step-definitions/cookie.steps.js:132"
|
|
176
|
-
},
|
|
177
|
-
"result": {
|
|
178
|
-
"status": "passed",
|
|
179
|
-
"duration": 1479906
|
|
180
|
-
}
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
"arguments": [
|
|
184
|
-
{
|
|
185
|
-
"content": "a=1&b=2",
|
|
186
|
-
"line": 16
|
|
187
|
-
}
|
|
188
|
-
],
|
|
189
|
-
"keyword": "When ",
|
|
190
|
-
"line": 15,
|
|
191
|
-
"name": "I send a REST \"POST\" request to \"http://localhost:8990/echo\" with body:",
|
|
192
|
-
"match": {
|
|
193
|
-
"location": "tests/step-definitions/rest.steps.js:88"
|
|
194
|
-
},
|
|
195
|
-
"result": {
|
|
196
|
-
"status": "passed",
|
|
197
|
-
"duration": 7299009
|
|
198
|
-
}
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
"arguments": [],
|
|
202
|
-
"keyword": "Then ",
|
|
203
|
-
"line": 19,
|
|
204
|
-
"name": "the REST response should contain \"session_id=abc123\"",
|
|
205
|
-
"match": {
|
|
206
|
-
"location": "tests/step-definitions/rest.steps.js:118"
|
|
207
|
-
},
|
|
208
|
-
"result": {
|
|
209
|
-
"status": "passed",
|
|
210
|
-
"duration": 308369
|
|
211
|
-
}
|
|
212
|
-
},
|
|
213
|
-
{
|
|
214
|
-
"arguments": [],
|
|
215
|
-
"keyword": "And ",
|
|
216
|
-
"line": 20,
|
|
217
|
-
"name": "the REST response should contain \"application/x-www-form-urlencoded\"",
|
|
218
|
-
"match": {
|
|
219
|
-
"location": "tests/step-definitions/rest.steps.js:118"
|
|
220
|
-
},
|
|
221
|
-
"result": {
|
|
222
|
-
"status": "passed",
|
|
223
|
-
"duration": 187290
|
|
224
|
-
}
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
"arguments": [],
|
|
228
|
-
"keyword": "And ",
|
|
229
|
-
"line": 21,
|
|
230
|
-
"name": "the REST response should contain \"a=1&b=2\"",
|
|
231
|
-
"match": {
|
|
232
|
-
"location": "tests/step-definitions/rest.steps.js:118"
|
|
233
|
-
},
|
|
234
|
-
"result": {
|
|
235
|
-
"status": "passed",
|
|
236
|
-
"duration": 100281
|
|
237
|
-
}
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
"arguments": [],
|
|
241
|
-
"keyword": "And ",
|
|
242
|
-
"line": 22,
|
|
243
|
-
"name": "a cookie with the name \"from_api\" should exist",
|
|
244
|
-
"match": {
|
|
245
|
-
"location": "tests/step-definitions/cookie.steps.js:32"
|
|
246
|
-
},
|
|
247
|
-
"result": {
|
|
248
|
-
"status": "passed",
|
|
249
|
-
"duration": 1266994
|
|
250
|
-
}
|
|
251
|
-
},
|
|
252
|
-
{
|
|
253
|
-
"keyword": "After",
|
|
254
|
-
"hidden": true,
|
|
255
|
-
"result": {
|
|
256
|
-
"status": "passed",
|
|
257
|
-
"duration": 97005
|
|
258
|
-
}
|
|
259
|
-
},
|
|
260
|
-
{
|
|
261
|
-
"keyword": "After",
|
|
262
|
-
"hidden": true,
|
|
263
|
-
"result": {
|
|
264
|
-
"status": "passed",
|
|
265
|
-
"duration": 18792075
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
],
|
|
269
|
-
"tags": [],
|
|
270
|
-
"type": "scenario"
|
|
271
|
-
}
|
|
272
|
-
],
|
|
273
|
-
"id": "cookie-check-(not-committed)",
|
|
274
|
-
"line": 1,
|
|
275
|
-
"keyword": "Feature",
|
|
276
|
-
"name": "cookie check (not committed)",
|
|
277
|
-
"tags": [],
|
|
278
|
-
"uri": ".scratch/features/cookies.feature"
|
|
279
|
-
}
|
|
280
|
-
]
|