Comments (8)
Thanks for leaving the issue and sorry for the wait. Will be investigating tomorrow
from stepci.
Wanted to come back to this. There's no Location
check in Step CI.
Could you clarify what you want to accomplish with the check?
from stepci.
I'm sorry, my example was buggy. Correct code for the check would be
check:
status: 301
headers:
Location: /foo
I'm not sure why I posted this, must have been copying from a wrong file.
Let me check tomorrow at work if this error I described is caused by my wrong code.
from stepci.
Are you sure https://httpbin.org/redirect-to?url=/foo&status_code=301 has a Location header?
from stepci.
This is the response I get when I request it with my regular http client
HTTP/1.1 404 NOT FOUND
Date: Tue, 18 Apr 2023 15:42:54 GMT
Content-Type: text/html
Content-Length: 233
Connection: close
Server: gunicorn/19.9.0
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>404 Not Found</title>
<h1>Not Found</h1>
<p>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.</p>
from stepci.
Are you sure you are using the correct URL?
# http -p h https://httpbin.org/redirect-to\?url\=/foo\&status_code\=301
HTTP/1.1 301 MOVED PERMANENTLY
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 0
Content-Type: text/html; charset=utf-8
Date: Tue, 18 Apr 2023 15:44:37 GMT
Location: /foo
Server: gunicorn/19.9.0
from stepci.
Have you tried checking redirects using redirects
check?
https://docs.stepci.com/reference/workflow-syntax.html#tests-test-steps-step-http-check-redirects
Example for your case would be:
check:
redirects:
- foo/
or
check:
redirects:
- https://httpbin.org/foo/
from stepci.
Thanks for your hint! I revisited my testcase:
version: "1.1"
name: redirect
config:
continueOnFail: true
tests:
redirect:
steps:
- name: httpbin
http:
url: https://httpbin.org/redirect-to?url=/foo&status_code=301
method: GET
check:
headers:
Location: /foo
redirects:
- /foo
- name: httpbin
http:
url: https://httpbin.org/redirect-to?url=/foo&status_code=301
method: GET
followRedirects: false
check:
headers:
Location: /foo
redirects:
- /foo
this is the result
FAIL redirect
Summary
✕ httpbin failed after 0.892s
✕ httpbin failed after 0.408s
● redirect › httpbin
Request HTTP
GET https://httpbin.org/foo HTTP/1.1
Response
HTTP/1.1 404 NOT FOUND
date: Wed 19 Apr 2023 06:53:41 GMT
content-type: text/html
content-length: 233
connection: close
server: gunicorn/19.9.0
access-control-allow-origin: *
access-control-allow-credentials: true
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>404 Not Found</title>
<h1>Not Found</h1>
<p>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.</p>
Checks
Headers
✕ Location: undefined (expected /foo)
undefined
✕ https://httpbin.org/foo (expected /foo)
● redirect › httpbin
Request HTTP
GET https://httpbin.org/redirect-to?url=/foo&status_code=301 HTTP/1.1
Response
HTTP/1.1 301 MOVED PERMANENTLY
date: Wed 19 Apr 2023 06:53:41 GMT
content-type: text/html; charset=utf-8
content-length: 0
connection: close
server: gunicorn/19.9.0
location: /foo
access-control-allow-origin: *
access-control-allow-credentials: true
Checks
Headers
✔ Location: /foo
undefined
✕ (expected /foo)
Tests: 1 failed, 0 passed, 1 total
Steps: 2 failed, 0 skipped, 0 passed, 2 total
Time: 1.888s, estimated 2s
CO2: 0.00008g
Workflow failed after 1.888s
So it seems to me, that the redirects
check does not check for the Location header, but simply follows all redirects and grabs the resulting URL, right? I couldn't confirm this in the runner's code, unfortunately.
So to check explicitly for the answer of the first redirect, I still have to set followRedirects: false
and can't use the check redirects
but have to check for the header Location
.
To come back to the original topic of this issue:
version: "1.1"
name: redirect
config:
continueOnFail: true
tests:
redirect:
steps:
- name: httpbin
http:
url: https://httpbin.org/redirect-to?url=/foo&status_code=301
method: GET
followRedirects: false
check:
headers:
Location: /foo/
This check should fail, cause the header Location
contains the string /foo
. That should not match /foo/
.
from stepci.
Related Issues (20)
- Add http info to load testing
- HTTP Signatures
- Allow throwing errors from runner
- Add test data on the workflow level (not just the test)
- Verbose mode HOT 1
- Shallow JSON check
- [Bug]: Can't seem to get templating working HOT 4
- [Feature Req]: Blanket `stepci run` support HOT 4
- Document delay step type
- Github Action crashes HOT 2
- Pin down versions to avoid breaking changes HOT 2
- Change how env are handled in the CLI
- [Bug]: Descriptive JSON Schema error objects HOT 4
- Posthog performance
- Add ability to mark tests as flaky
- [Bug]: Github Actions overrides workdir HOT 1
- [Bug]: Array query parameter HOT 9
- [Bug]: Resolving local file references does not work HOT 2
- [Bug]: `faker_1.faker[module][type] is not a function` HOT 1
- [Bug]: filename field in Content-Disposition is missing for file upload HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stepci.