2023-03-14 13:18:55 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
2023-08-11 13:12:13 +00:00
|
|
|
* SPDX-License-Identifier: BUSL-1.1
|
2023-03-14 13:18:55 +00:00
|
|
|
*/
|
|
|
|
|
2022-09-15 08:43:17 +00:00
|
|
|
export default function (scenario, respondWith, set, oidc) {
|
2019-02-21 13:05:05 +00:00
|
|
|
// respondWith should set the url to return a certain response shape
|
|
|
|
scenario
|
2022-09-15 08:43:17 +00:00
|
|
|
.given(['the url "$endpoint" responds with a $status status'], function (url, status) {
|
2019-02-21 13:05:05 +00:00
|
|
|
respondWith(url, {
|
|
|
|
status: parseInt(status),
|
|
|
|
});
|
|
|
|
})
|
2022-09-15 08:43:17 +00:00
|
|
|
.given(['the url "$endpoint" responds with from yaml\n$yaml'], function (url, data) {
|
2021-02-19 16:42:16 +00:00
|
|
|
if (typeof data.body !== 'string') {
|
|
|
|
data.body = JSON.stringify(data.body);
|
|
|
|
}
|
2019-02-21 13:05:05 +00:00
|
|
|
respondWith(url, data);
|
|
|
|
})
|
2022-09-15 08:43:17 +00:00
|
|
|
.given(['the "$provider" oidcProvider responds with from yaml\n$yaml'], function (name, data) {
|
2022-01-11 11:02:46 +00:00
|
|
|
oidc(name, data);
|
|
|
|
})
|
2022-09-15 08:43:17 +00:00
|
|
|
.given('a network latency of $number', function (number) {
|
2019-02-21 13:05:05 +00:00
|
|
|
set('CONSUL_LATENCY', number);
|
2022-09-06 10:13:51 +00:00
|
|
|
})
|
2022-09-15 08:43:17 +00:00
|
|
|
.given('an API prefix of "$prefix"', function (prefix) {
|
2022-09-06 10:13:51 +00:00
|
|
|
set('CONSUL_API_PREFIX', prefix);
|
2019-02-21 13:05:05 +00:00
|
|
|
});
|
|
|
|
}
|