Skip to content

Commit

Permalink
Remove httpbin references (59 remain)
Browse files Browse the repository at this point in the history
  • Loading branch information
federicotdn committed Jan 9, 2025
1 parent 1b9b322 commit f6eb2f1
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 50 deletions.
43 changes: 7 additions & 36 deletions docs/sources/k6/next/examples/http-authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function () {

// Passing username and password as part of the URL will
// allow us to authenticate using HTTP Basic Auth.
const url = `https://${credentials}@httpbin.test.k6.io/basic-auth/${username}/${password}`;
const url = `http://${credentials}@quickpizza.grafana-dev.com:3333/api/basic-auth/${username}/${password}`;

let res = http.get(url);

Expand All @@ -45,7 +45,10 @@ export default function () {
},
};

res = http.get(`https://httpbin.test.k6.io/basic-auth/${username}/${password}`, options);
res = http.get(
`http://quickpizza.grafana-dev.com:3333/api/basic-auth/${username}/${password}`,
options
);

// Verify response (checking the echoed data from the httpbin.test.k6.io
// basic auth test API endpoint)
Expand All @@ -59,40 +62,6 @@ export default function () {

{{< /code >}}

## Digest authentication

{{< code >}}

```javascript
import http from 'k6/http';
import { check } from 'k6';

const username = 'user';
const password = 'passwd';

export default function () {
// Passing username and password as part of URL plus the auth option will
// authenticate using HTTP Digest authentication.
const credentials = `${username}:${password}`;
const res = http.get(
`https://${credentials}@httpbin.test.k6.io/digest-auth/auth/${username}/${password}`,
{
auth: 'digest',
}
);

// Verify response (checking the echoed data from the httpbin.test.k6.io digest auth
// test API endpoint)
check(res, {
'status is 200': (r) => r.status === 200,
'is authenticated': (r) => r.json().authenticated === true,
'is correct user': (r) => r.json().user === username,
});
}
```

{{< /code >}}

## NTLM authentication

{{< code >}}
Expand Down Expand Up @@ -121,6 +90,8 @@ Here's an example script to demonstrate how to sign a request to fetch an object

{{< code >}}

<!-- md-k6:skip -->

```javascript
import http from 'k6/http';
import {
Expand Down
2 changes: 1 addition & 1 deletion docs/sources/k6/next/javascript-api/jslib/httpx/patch.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ weight: 13
import { Httpx } from 'https://jslib.k6.io/httpx/0.1.0/index.js';

const session = new Httpx({
baseURL: 'https://httpbin.test.k6.io',
baseURL: 'http://quickpizza.grafana-dev.com:3333/api',
timeout: 20000, // 20s timeout.
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ import http from 'k6/http';
import { check } from 'k6';

export default function () {
const res = http.get('https://httpbin.test.k6.io/cookies/set?my_cookie=hello%20world', {
redirects: 0,
});
const res = http.post(
'http://quickpizza.grafana-dev.com:3333/api/cookies?my_cookie=hello%20world',
{
redirects: 0,
}
);
const jar = http.cookieJar();
const cookies = jar.cookiesForURL('https://httpbin.test.k6.io/');
const cookies = jar.cookiesForURL('http://quickpizza.grafana-dev.com:3333/api/cookies');
check(res, {
"has cookie 'my_cookie'": (r) => cookies.my_cookie.length > 0,
'cookie has correct value': (r) => cookies.my_cookie[0] === 'hello world',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import { check } from 'k6';

export default function () {
const jar = http.cookieJar();
jar.set('https://httpbin.test.k6.io/cookies', 'my_cookie_1', 'hello world_1');
jar.set('https://httpbin.test.k6.io/cookies', 'my_cookie_2', 'hello world_2');
jar.set('http://quickpizza.grafana-dev.com:3333/api/cookies', 'my_cookie_1', 'hello world_1');
jar.set('http://quickpizza.grafana-dev.com:3333/api/cookies', 'my_cookie_2', 'hello world_2');

const res1 = http.get('https://httpbin.test.k6.io/cookies');
const res1 = http.get('http://quickpizza.grafana-dev.com:3333/api/cookies');
check(res1, {
'res1 has status 200': (r) => r.status === 200,
"res1 has cookie 'my_cookie_1'": (r) => r.json().cookies.my_cookie_1 !== null,
Expand All @@ -32,9 +32,9 @@ export default function () {
'res1 cookie has correct value_2': (r) => r.json().cookies.my_cookie_2 == 'hello world_2',
});

jar.delete('https://httpbin.test.k6.io/cookies', 'my_cookie_1');
jar.delete('http://quickpizza.grafana-dev.com:3333/api/cookies', 'my_cookie_1');

const res2 = http.get('https://httpbin.test.k6.io/cookies');
const res2 = http.get('http://quickpizza.grafana-dev.com:3333/api/cookies');
check(res2, {
'res2 has status 200': (r) => r.status === 200,
"res2 doesn't have cookie 'my_cookie_1'": (r) => r.json().cookies.my_cookie_1 == null,
Expand Down
2 changes: 1 addition & 1 deletion docs/sources/k6/next/javascript-api/k6-http/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ weight: 10
```javascript
import http from 'k6/http';

const url = 'https://httpbin.test.k6.io/';
const url = 'http://quickpizza.grafana-dev.com:3333/';

export default function () {
const params = { headers: { 'X-MyHeader': 'k6test' } };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ const only300Callback = http.expectedStatuses(300);

export default () => {
// this will use the default response callback and be marked as successful
http.get('https://httpbin.test.k6.io/status/200');
http.get('http://quickpizza.grafana-dev.com:3333/api/status/200');

// this will be marked as a failed request as it won't get the expected status code of 300
http.get('https://httpbin.test.k6.io/status/200', { responseCallback: only300Callback });
http.get('http://quickpizza.grafana-dev.com:3333/api/status/200', {
responseCallback: only300Callback,
});

http.setResponseCallback(http.expectedStatuses(301));
// from here on for this VU only the 301 status code will be successful so on the next iteration of
Expand Down
2 changes: 1 addition & 1 deletion docs/sources/k6/next/results-output/real-time/json.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ The JSON output has lines as follows:
{"type":"Metric","data":{"type":"gauge","contains":"default","tainted":null,"thresholds":[],"submetrics":null},"metric":"vus"}
{"type":"Point","data":{"time":"2017-05-09T14:34:45.625742514+02:00","value":5,"tags":null},"metric":"vus"}
{"type":"Metric","data":{"type":"trend","contains":"time","tainted":null,"thresholds":["avg<1000"],"submetrics":null},"metric":"http_req_duration"}
{"type":"Point","data":{"time":"2017-05-09T14:34:45.239531499+02:00","value":459.865729,"tags":{"group":"::my group::json","method":"GET","status":"200","url":"https://httpbin.test.k6.io/get"}},"metric":"http_req_duration"}
{"type":"Point","data":{"time":"2017-05-09T14:34:45.239531499+02:00","value":459.865729,"tags":{"group":"::my group::json","method":"GET","status":"200","url":"https://quickpizza.grafana.com/api/tools"}},"metric":"http_req_duration"}
```

{{< /code >}}
Expand Down

0 comments on commit f6eb2f1

Please sign in to comment.