ui: Move mocks into the ui project (#9084)

* Add consul-api-double under api

* Update config to reflect api change

* Remove consul-api-double as a dependency

* api -> mock-api

* Fixup mocks path for staging
This commit is contained in:
John Cowen 2020-11-05 16:03:49 +00:00 committed by GitHub
parent c2d167d06e
commit 5875e4b15b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
85 changed files with 3066 additions and 8 deletions

View File

@ -6,10 +6,6 @@
"workspaces": {
"packages": [
"packages/*"
],
"nohoist": [
"**/@hashicorp/consul-api-double",
"**/@hashicorp/consul-api-double/**"
]
},
"scripts": {

View File

@ -120,7 +120,7 @@ module.exports = function(environment, $ = process.env) {
'auto-import': false,
enabled: true,
endpoints: {
'/v1': '/node_modules/@hashicorp/consul-api-double/v1',
'/v1': '/mock-api/v1',
},
},
APP: Object.assign({}, ENV.APP, {
@ -150,7 +150,7 @@ module.exports = function(environment, $ = process.env) {
'@hashicorp/ember-cli-api-double': {
enabled: true,
endpoints: {
'/v1': '/node_modules/@hashicorp/consul-api-double/v1',
'/v1': '/mock-api/v1',
},
},
});

View File

@ -24,7 +24,7 @@ module.exports = {
// so we can set this path name centrally in config
// TODO: undefined here is a possible faker salt that we should be able
// to pass in from ember serve/config somehow
const dir = path.resolve('./node_modules/@hashicorp/consul-api-double');
const dir = path.resolve('./mock-api');
const controller = apiDouble(undefined, dir, read, $, path.resolve);
[
apiDoubleHeaders(),

View File

@ -0,0 +1,7 @@
# consul-api-double
Super simple API 'double' for easily visualizing the Consul API via the filesystem.
This can be served via either a simple javascript HTTP server, or entirely via frontend methods if your project/circumstances means you are unable to use or it's complicated to use a backend server for testing.
See [@hashicorp/api-double](https://github.com/hashicorp/api-double/) for more details.

View File

@ -0,0 +1,8 @@
---
"*":
GET:
"*":
latency: ${ location.search.index ? env('CONSUL_LATENCY', 60000) : env('CONSUL_LATENCY', 0) }
headers:
response:
X-Consul-Index: ${ parseInt((location.search.index || 1)) + 1}

View File

@ -0,0 +1,14 @@
---
"*":
GET:
"*":
latency: ${ location.search.index ? env('CONSUL_LATENCY', 60000) : env('CONSUL_LATENCY', 0) }
headers:
response:
Status-Code: ${
// when legacy is enabled tokens and policies return a 500
(env('CONSUL_ACLS_LEGACY', false) && (location.pathname.get(2) === 'tokens' || location.pathname.get(2) === 'policies')) ?
500 :
env('CONSUL_ACLS_ENABLE', false) ? (headers['x-consul-token'] !== '' ? 200 : 403) : 401
}
X-Consul-Index: ${ parseInt((location.search.index || 1)) + 1}

View File

@ -0,0 +1,28 @@
${
location.pathname.get(2) === 'policy' && http.method === 'PUT' ? `
{
"ID": "${fake.random.uuid()}-1",
"Name": "${body.Name || ''}",
"Description": "${body.Description || ''}",
"Datacenters": ${fake.helpers.randomize(['null', '["dc-1", "dc-2"]'])},
"Rules": "${body.Rules || ''}"
}
` : location.pathname.get(2) === 'token' && http.method === 'PUT' ?
`
{
"AccessorID":"${fake.random.uuid()}-1",
"SecretID":"${fake.random.uuid()}",
"Name": "${body.Name || ''}",
"Policies": ["dc2-service-register", "global-service-read"],
"CreateTime":"2017-08-23T22:47:14.695408057Z",
"CreateIndex":7,
"ModifyIndex":7
}
` : location.pathname.get(2) === 'role' && http.method === 'PUT' ?
`
{
"ID": "${fake.random.uuid()}-1"
}
` : `true`
}

View File

@ -0,0 +1 @@
true

View File

@ -0,0 +1,13 @@
---
"*":
GET:
"*":
latency: ${ location.search.index ? env('CONSUL_LATENCY', 60000) : env('CONSUL_LATENCY', 0) }
headers:
response:
Status-Code: ${
env('CONSUL_ACLS_LEGACY', false) ?
500 :
env('CONSUL_ACLS_ENABLE', false) ? (headers['x-consul-token'] !== '' ? 200 : 403) : 401
}
X-Consul-Index: ${ parseInt((location.search.index || 1)) + 1}

View File

@ -0,0 +1,10 @@
{
"Name": "${location.pathname.get(3)}",
"Description": "${fake.lorem.sentence()}",
"Type": "${fake.helpers.randomize(['kubernetes'])}", ${''/* oidc */}
"KubernetesHost": "https://${fake.internet.ip()}:8443",
"KubernetesCACert": "-----BEGIN CERTIFICATE-----${fake.internet.password(1357)}-----END CERTIFICATE-----",
"KubernetesServiceAccountJWT": "eyJhbGciOiJ${fake.internet.password(25)}.eyJ${fake.internet.password(61)}.${fake.internet.password(32)}",
"CreateIndex": 10,
"ModifyIndex": 10
}

View File

@ -0,0 +1,30 @@
${ env('CONSUL_ACLS_LEGACY', false) ? `rpc error making call: rpc: can't find method ACL.Method` : `
[
${
range(
env(
'CONSUL_IDP_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_IDP_MAX', 10)
) + parseInt(env('CONSUL_IDP_MIN', 1))
)
)
).map(
function(item, i) {
const type = fake.helpers.randomize(['kubernetes']); // oidc
return `
{
"Name": "idp-${i}",
"Description": "${fake.lorem.sentence()}",
"Type": "${type}",
${ type === 'kubernetes' ? `"KubernetesHost": "https://${fake.internet.ip()}:8443",` : ``}
"CreateIndex": 10,
"ModifyIndex": 10
}
`
}
)
}
]
`}

View File

@ -0,0 +1,19 @@
[
{
"ID":"${ location.pathname.get(3) }",
"Name":"${ location.pathname.get(3) } Token",
"Type":"${fake.helpers.randomize(['client', 'management'])}",
"Rules":${
JSON.stringify(
`agent "${fake.hacker.noun()}" {
policy = "write"
}
node "node-0" {
policy = "read"
}`
)
},
"CreateIndex":4,
"ModifyIndex":4
}
]

View File

@ -0,0 +1,71 @@
${
env('CONSUL_ENABLE_ACLS', 1) ? `
[
${
(count = env(
'CONSUL_ACL_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_ACL_MAX', 10)
) + parseInt(env('CONSUL_ACL_MIN', 2))
)
)) >= 2 ? `
{
"ID":"anonymous",
"Name":"Anonymous Token",
"Type":"client",
"Rules":"",
"CreateIndex":4,
"ModifyIndex":4
},
{
"ID":"secret",
"Name":"Master Token",
"Type":"management",
"Rules":"",
"CreateIndex":5,
"ModifyIndex":5
}${count > 2 ? "," : ""}
${
range(
Math.max(0, count - 2)
).map(
function(item, i) {
return `{
"ID":"${fake.lorem.word()}-${i}",
"Name":"${fake.lorem.word()}-${i}",
"Type":"client",
"Rules":"",
"CreateIndex":5,
"ModifyIndex":5
}`;
}
)
}` : `
${
range(
env(
'CONSUL_ACL_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_ACL_MAX', 10)
) + parseInt(env('CONSUL_ACL_MIN', 1))
)
)
).map(
function(item, i) {
return `{
"ID":"${fake.lorem.word()}-${i}",
"Name":"${fake.lorem.word()}-${i}",
"Type":"client",
"Rules":"",
"CreateIndex":5,
"ModifyIndex":5
}`;
}
)
}
`}
]
` : "ACL support disabled"
}

View File

@ -0,0 +1,3 @@
{
"AuthURL": "${env('CONSUL_OIDC_PROVIDER_URL')}&redirect_uri=${encodeURIComponent(http.body.RedirectURI)}&response_type=code&scope=openid"
}

View File

@ -0,0 +1,40 @@
{
"AccessorID": "${fake.random.uuid()}",
"SecretID": "${fake.random.uuid()}",
"Namespace": "${
typeof location.search.ns !== 'undefined' ? location.search.ns :
typeof http.body.Namespace !== 'undefined' ? http.body.Namespace : 'default'
}",
"Local": false,
"Description": "${fake.lorem.sentence()}",
"Policies": [
${
range(env('CONSUL_POLICY_COUNT', 3)).map(
function(item, i) {
return `
{
"ID": "${fake.random.uuid()}-${i}",
"Name": "${location.search.policy || fake.hacker.noun()}"
}
`;
}
)
}
],
"Roles": [
${
range(env('CONSUL_ROLE_COUNT', 10)).map(
function(item, j) {
return `
{
"ID": "${fake.random.uuid()}",
"Name": "${location.search.role || fake.hacker.noun()}"
}
`;
}
)
}
],
"CreateTime": "2019-10-11T11:24:06.1385039Z"
}

View File

@ -0,0 +1,46 @@
${ env('CONSUL_ACLS_LEGACY', false) ? `rpc error making call: rpc: can't find method ACL.Method` : `
[
${
range(
env(
'CONSUL_POLICY_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_POLICY_MAX', 10)
) + parseInt(env('CONSUL_POLICY_MIN', 1))
)
)
).map(
function(item, i) {
if(i === 1) {
return `
{
"ID": "00000000-0000-0000-0000-000000000001",
"Name": "global-management",
${typeof location.search.ns !== 'undefined' ? `
"Namespace": "${location.search.ns}",
` : ``}
"Description": "Built-In Management Policy",
"CreateIndex": 10,
"ModifyIndex": 10
}
`
}
return `
{
"ID": "${fake.random.uuid()}",
"Name": "${fake.hacker.noun()}-${i}",
${typeof location.search.ns !== 'undefined' ? `
"Namespace": "${location.search.ns}",
` : ``}
"Description": "${fake.lorem.sentence()}",
"Datacenters": ${fake.helpers.randomize(['["aq west-5", "ch east-4"]'])},
"CreateIndex": 10,
"ModifyIndex": 10
}
`
}
)
}
]
`}

View File

@ -0,0 +1,13 @@
---
"*":
GET:
"*":
latency: ${ location.search.index ? env('CONSUL_LATENCY', 60000) : env('CONSUL_LATENCY', 0) }
headers:
response:
Status-Code: ${
env('CONSUL_ACLS_LEGACY', false) ?
500 :
env('CONSUL_ACLS_ENABLE', false) ? (headers['x-consul-token'] !== '' ? 200 : 403) : 401
}
X-Consul-Index: ${ parseInt((location.search.index || 1)) + 1}

View File

@ -0,0 +1,17 @@
{
"ID": "${location.pathname.get(3)}",
"Namespace": "${
typeof location.search.ns !== 'undefined' ? location.search.ns :
typeof http.body.Namespace !== 'undefined' ? http.body.Namespace : 'default'
}",
"Description": "${location.pathname.get(3) === '00000000-0000-0000-0000-000000000001' ? 'Built-in Management Policy' : fake.lorem.sentence()}",
${ location.pathname.get(3) !== '00000000-0000-0000-0000-000000000001' ? `
"Datacenters": ${fake.helpers.randomize(['["aq west-5", "ch east-4"]'])},
"Rules": ${JSON.stringify(
`key "foo" {
policy = "write"
}`)},
` : "" }
"Name": "${location.pathname.get(3) === '00000000-0000-0000-0000-000000000001' ? 'global-management' : fake.hacker.noun() + '-policy'}"
}

View File

@ -0,0 +1,8 @@
key_prefix "foo" {
permission = "read"
}
operator {
permission = "read"
}

View File

@ -0,0 +1,64 @@
{
"ID": "${location.pathname.get(3)}",
"Name": "${fake.hacker.noun() + '-role'}",
"Namespace": "${
typeof location.search.ns !== 'undefined' ? location.search.ns :
typeof http.body.Namespace !== 'undefined' ? http.body.Namespace : 'default'
}",
"Description": "${fake.lorem.sentence()}",
"Policies": [
${
range(env('CONSUL_POLICY_COUNT', 3)).map(
function(item, i) {
return `
{
"ID": "${fake.random.uuid()}-${i}",
"Name": "${fake.hacker.noun()}"
}
`;
}
)
}
],
"ServiceIdentities": [
${
range(env('CONSUL_SERVICE_IDENTITY_COUNT', env('CONSUL_IDENTITY_COUNT', 1))).map(
function(item, i) {
return `
{
"ServiceName": "${fake.hacker.noun()}"${ fake.random.boolean() ? `,
"Datacenters": [
${
range(env('CONSUL_DATACENTER_COUNT', fake.random.number({min: 1, max: 10}))).map(
function(item, i) {
return `"${fake.address.countryCode().toLowerCase()} ${ i % 2 ? "west" : "east"}-${i}"`;
}
)
}
]
` : ``}
}
`;
}
)
}
],
"NodeIdentities": [
${
range(env('CONSUL_NODE_IDENTITY_COUNT', 1)).map(
function(item, i) {
return `
{
"NodeName": "${fake.hacker.noun()}",
"Datacenter":"${fake.address.countryCode().toLowerCase()} ${ i % 2 ? "west" : "east"}-${i}"
}
`;
}
)
}
],
"Hash": "${fake.internet.password(64)}=",
"CreateIndex": 57,
"ModifyIndex": 57
}

View File

@ -0,0 +1,13 @@
---
"*":
GET:
"*":
latency: ${ location.search.index ? env('CONSUL_LATENCY', 60000) : env('CONSUL_LATENCY', 0) }
headers:
response:
Status-Code: ${
env('CONSUL_ACLS_LEGACY', false) ?
500 :
env('CONSUL_ACLS_ENABLE', false) ? (headers['x-consul-token'] !== '' ? 200 : 403) : 401
}
X-Consul-Index: ${ parseInt((location.search.index || 1)) + 1}

View File

@ -0,0 +1,30 @@
{
"ID": "${location.pathname.get(3)}",
"IDPName": "${fake.hacker.noun()}-idp",
"RoleName": "${ fake.random.boolean() ? `${fake.hacker.noun()}-role` : `${fake.hacker.noun()}-{{ serviceaccount.name }}`}",
"Description": "${fake.lorem.sentence()}",
"Matches": [
${
range(env('CONSUL_MATCH_COUNT', 3)).map(
function(item, i) {
return `
{
"Selectors": [
${
range(env('CONSUL_SELECTOR_COUNT', fake.random.number({min: 1, max: 5}))).map(
function(item, i) {
return `"serviceaccount.name=${fake.hacker.noun()}"`;
}
)
}
]
}
`;
}
)
}
],
"MustExist": ${fake.helpers.randomize(['true', 'false'])},
"CreateIndex": 10,
"ModifyIndex": 10
}

View File

@ -0,0 +1,49 @@
${ env('CONSUL_ACLS_LEGACY', false) ? `rpc error making call: rpc: can't find method ACL.Method` : `
[
${
range(
env(
'CONSUL_BINDING_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_BINDING_MAX', 10)
) + parseInt(env('CONSUL_BINDING_MIN', 1))
)
)
).map(
function(item, i) {
return `
{
"Description": "${fake.lorem.sentence()}",
"IDPName": "${fake.hacker.noun()}-idp",
"Matches": [
${
range(env('CONSUL_MATCH_COUNT', 3)).map(
function(item, i) {
return `
{
"Selectors": [
${
range(env('CONSUL_SELECTOR_COUNT', fake.random.number({min: 1, max: 5}))).map(
function(item, i) {
return `"serviceaccount.name=${fake.hacker.noun()}"`;
}
)
}
]
}
`;
}
)
}
],
"RoleName": "${ fake.random.boolean() ? `role-{$i}` : `{{ serviceaccount.name }}`}",
"CreateIndex": 10,
"ModifyIndex": 10
}
`
}
)
}
]
`}

View File

@ -0,0 +1,90 @@
${ env('CONSUL_ACLS_LEGACY', false) ? `rpc error making call: rpc: can't find method ACL.Method` : `
[
${
range(
env(
'CONSUL_ROLE_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_ROLE_MAX', 10)
) + parseInt(env('CONSUL_ROLE_MIN', 1))
)
)
).map(
function(item, i) {
return `
{
"ID": "${fake.random.uuid()}",
"Name": "${fake.hacker.noun()}-${i}",
${typeof location.search.ns !== 'undefined' ? `
"Namespace": "${location.search.ns}",
` : ``}
"Description": "${fake.lorem.sentence()}",
"Policies": [
${
range(env('CONSUL_POLICY_COUNT', 10)).map(
function(item, j) {
if(i == 1 && j == 0) {
return `
{
"ID": "00000000-0000-0000-0000-000000000001",
"Name": "global-management"
}
`;
}
return `
{
"ID": "${fake.random.uuid()}",
"Name": "${fake.hacker.noun()}"
}
`;
}
)
}
],
"ServiceIdentities": [
${
range(env('CONSUL_SERVICE_IDENTITY_COUNT', env('CONSUL_IDENTITY_COUNT', 1))).map(
function(item, i) {
return `
{
"ServiceName": "${fake.hacker.noun()}"${ fake.random.boolean() ? `,
"Datacenters": [
${
range(env('CONSUL_DATACENTER_COUNT', fake.random.number({min: 1, max: 10}))).map(
function(item, i) {
return `"${fake.address.countryCode().toLowerCase()} ${ i % 2 ? "west" : "east"}-${i}"`;
}
)
}
]
` : ``}
}
`;
}
)
}
],
"NodeIdentities": [
${
range(env('CONSUL_NODE_IDENTITY_COUNT', 1)).map(
function(item, i) {
return `
{
"NodeName": "${fake.hacker.noun()}",
"Datacenter":"${fake.address.countryCode().toLowerCase()} ${ i % 2 ? "west" : "east"}-${i}"
}
`;
}
)
}
],
"CreateIndex": ${fake.random.number()},
"ModifyIndex": 10
}
`
}
)
}
]
`}

View File

@ -0,0 +1,13 @@
---
"*":
GET:
"*":
latency: ${ location.search.index ? env('CONSUL_LATENCY', 60000) : env('CONSUL_LATENCY', 0) }
headers:
response:
Status-Code: ${
env('CONSUL_ACLS_LEGACY', false) ?
500 :
env('CONSUL_ACLS_ENABLE', false) ? (headers['x-consul-token'] !== '' ? 200 : 403) : 401
}
X-Consul-Index: ${ parseInt((location.search.index || 1)) + 1}

View File

@ -0,0 +1,98 @@
{
"AccessorID": "${location.pathname.get(3)}",
"SecretID":"${fake.random.uuid()}",
"IDPName": "${fake.hacker.noun()}",
"Namespace": "${
typeof location.search.ns !== 'undefined' ? location.search.ns :
typeof http.body.Namespace !== 'undefined' ? http.body.Namespace : 'default'
}",
${ location.pathname.get(3) === '00000000-0000-0000-0000-000000000002' ?
`
"Name": "${fake.hacker.noun()}",
"Type":"${fake.helpers.randomize(['client', 'management'])}",
"Rules": ${
JSON.stringify(
`agent "${fake.hacker.noun()}" {
policy = "write"
}
node "node-0" {
policy = "read"
}`
)
},
`
:
`
"Policies": [
${
range(env('CONSUL_POLICY_COUNT', 3)).map(
function(item, i) {
return `
{
"ID": "${fake.random.uuid()}-${i}",
"Name": "${fake.hacker.noun()}"
}
`;
}
)
}
],
"Roles": [
${
range(env('CONSUL_ROLE_COUNT', 10)).map(
function(item, j) {
return `
{
"ID": "${fake.random.uuid()}",
"Name": "${fake.hacker.noun()}"
}
`;
}
)
}
],
"ServiceIdentities": [
${
range(env('CONSUL_SERVICE_IDENTITY_COUNT', env('CONSUL_IDENTITY_COUNT', 1))).map(
function(item, i) {
return `
{
"ServiceName": "${fake.hacker.noun()}"${ fake.random.boolean() ? `,
"Datacenters": [
${
range(env('CONSUL_DATACENTER_COUNT', fake.random.number({min: 1, max: 10}))).map(
function(item, i) {
return `"${fake.address.countryCode().toLowerCase()} ${ i % 2 ? "west" : "east"}-${i}"`;
}
)
}
]
` : ``}
}
`;
}
)
}
],
"NodeIdentities": [
${
range(env('CONSUL_NODE_IDENTITY_COUNT', 1)).map(
function(item, i) {
return `
{
"NodeName": "${fake.hacker.noun()}",
"Datacenter":"${fake.address.countryCode().toLowerCase()} ${ i % 2 ? "west" : "east"}-${i}"
}
`;
}
)
}
],
${ fake.random.boolean() ? '"Local": true,' : "" }
`
}
"CreateTime":"2017-08-23T22:47:14.695408057Z",
"CreateIndex":7,
"ModifyIndex":7
}

View File

@ -0,0 +1,42 @@
${ env('CONSUL_ACLS_LEGACY', false) ? `rpc error making call: rpc: can't find method ACL.Method` : `
{
"AccessorID": "${fake.random.uuid()}",
"SecretID": ${typeof headers['X-Consul-Token'] !== 'undefined' ? '"' + headers['X-Consul-Token'] + '"' : null},
"Namespace": "${
typeof location.search.ns !== 'undefined' ? location.search.ns :
typeof http.body.Namespace !== 'undefined' ? http.body.Namespace : 'default'
}",
"Local": false,
"Description": "${fake.lorem.sentence()}",
"Policies": [
${
range(env('CONSUL_POLICY_COUNT', 3)).map(
function(item, i) {
return `
{
"ID": "${fake.random.uuid()}-${i}",
"Name": "${location.search.policy || fake.hacker.noun()}"
}
`;
}
)
}
],
"Roles": [
${
range(env('CONSUL_ROLE_COUNT', 10)).map(
function(item, j) {
return `
{
"ID": "${fake.random.uuid()}",
"Name": "${location.search.role || fake.hacker.noun()}"
}
`;
}
)
}
],
"CreateTime": "2019-10-11T11:24:06.1385039Z"
}
`}

View File

@ -0,0 +1,108 @@
${ env('CONSUL_ACLS_LEGACY', false) ? `rpc error making call: rpc: can't find method ACL.Method` : `
[
${
range(
env(
'CONSUL_TOKEN_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_TOKEN_MAX', 10)
) + parseInt(env('CONSUL_TOKEN_MIN', 1))
)
)
).map(
function(item, i) {
return `
{
"AccessorID": "${i === 1 ? '00000000-0000-0000-0000-000000000002' : fake.random.uuid()}",
"Name": "token-${i}",
${typeof location.search.ns !== 'undefined' ? `
"Namespace": "${location.search.ns}",
` : ``}
"IDPName": "${fake.hacker.noun()}",
"Policies": [
${
range(env('CONSUL_POLICY_COUNT', 10)).map(
function(item, j) {
if(i == 1 && j == 0) {
return `
{
"ID": "00000000-0000-0000-0000-000000000001",
"Name": "global-management"
}
`;
}
return `
{
"ID": "${fake.random.uuid()}",
"Name": "${fake.hacker.noun()}"
}
`;
}
)
}
],
"Roles": [
${
range(env('CONSUL_ROLE_COUNT', 10)).map(
function(item, j) {
return `
{
"ID": "${fake.random.uuid()}",
"Name": "${fake.hacker.noun()}"
}
`;
}
)
}
],
"ServiceIdentities": [
${
range(env('CONSUL_SERVICE_IDENTITY_COUNT', env('CONSUL_IDENTITY_COUNT', 1))).map(
function(item, i) {
return `
{
"ServiceName": "${fake.hacker.noun()}"${ fake.random.boolean() ? `,
"Datacenters": [
${
range(env('CONSUL_DATACENTER_COUNT', fake.random.number({min: 1, max: 10}))).map(
function(item, i) {
return `"${fake.address.countryCode().toLowerCase()} ${ i % 2 ? "west" : "east"}-${i}"`;
}
)
}
]
` : ``}
}
`;
}
)
}
],
"NodeIdentities": [
${
range(env('CONSUL_NODE_IDENTITY_COUNT', 1)).map(
function(item, i) {
return `
{
"NodeName": "${fake.hacker.noun()}",
"Datacenter":"${fake.address.countryCode().toLowerCase()} ${ i % 2 ? "west" : "east"}-${i}"
}
`;
}
)
}
],
${ fake.random.boolean() && i !== 1 ? '"Legacy": true,' : "" }
${ fake.random.boolean() ? '"Local": true,' : "" }
"CreateTime": "${fake.date.past(10).toISOString()}",
"Hash": "${fake.internet.password(64)}=",
"CreateIndex": 10,
"ModifyIndex": 10
}
`
}
)
}
]
`}

View File

@ -0,0 +1,3 @@
{
"ID": "${body.ID}"
}

View File

@ -0,0 +1,13 @@
${
true ? `
{
"Authorized": true,
"Reason": "matches intention XXX"
}
` : `
{
"Authorized": false,
"Reason": "denied by intention XXX"
}
`
}

View File

@ -0,0 +1,11 @@
{
"SerialNumber": "08",
"CertPEM": "-----BEGIN CERTIFICATE-----\nMIIChjCCAi2gAwIBAgIBCDAKBggqhkjOPQQDAjAWMRQwEgYDVQQDEwtDb25zdWwg\nQ0EgNzAeFw0xODA1MjExNjMzMjhaFw0xODA1MjQxNjMzMjhaMA4xDDAKBgNVBAMT\nA3dlYjBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABJdLqRKd1SRycFOFceMHOBZK\nQW8HHO8jZ5C8dRswD+IwTd/otJPiaPrVzGOAi4MsaEUgDMemvN1jiywHt3II08mj\nggFyMIIBbjAOBgNVHQ8BAf8EBAMCA7gwHQYDVR0lBBYwFAYIKwYBBQUHAwIGCCsG\nAQUFBwMBMAwGA1UdEwEB/wQCMAAwaAYDVR0OBGEEXzFmOjkxOmNhOjQxOjhmOmFj\nOjY3OmJmOjU5OmMyOmZhOjRlOjc1OjVjOmQ4OmYwOjU1OmRlOmJlOjc1OmI4OjMz\nOjMxOmQ1OjI0OmIwOjA0OmIzOmU4Ojk3OjViOjdlMGoGA1UdIwRjMGGAXzFmOjkx\nOmNhOjQxOjhmOmFjOjY3OmJmOjU5OmMyOmZhOjRlOjc1OjVjOmQ4OmYwOjU1OmRl\nOmJlOjc1OmI4OjMzOjMxOmQ1OjI0OmIwOjA0OmIzOmU4Ojk3OjViOjdlMFkGA1Ud\nEQRSMFCGTnNwaWZmZTovLzExMTExMTExLTIyMjItMzMzMy00NDQ0LTU1NTU1NTU1\nNTU1NS5jb25zdWwvbnMvZGVmYXVsdC9kYy9kYzEvc3ZjL3dlYjAKBggqhkjOPQQD\nAgNHADBEAiBS8kH3UERhBPHM/CQV/jXKLr0kReLqCdq1jZxc8Aq7hQIgFIus/ZX0\nOM/X3Yc1xb/qJiiEVzXcaz3oVFULOzrNAwk=\n-----END CERTIFICATE-----\n",
"PrivateKeyPEM": "-----BEGIN EC PRIVATE KEY-----\nMHcCAQEEIAOGglbwY8HdD3LFX6Bc94co2pzeFTto8ebWoML5E+QfoAoGCCqGSM49\nAwEHoUQDQgAEl0upEp3VJHJwU4Vx4wc4FkpBbwcc7yNnkLx1GzAP4jBN3+i0k+Jo\n+tXMY4CLgyxoRSAMx6a83WOLLAe3cgjTyQ==\n-----END EC PRIVATE KEY-----\n",
"Service": "web",
"ServiceURI": "spiffe://11111111-2222-3333-4444-555555555555.consul/ns/default/dc/dc1/svc/web",
"ValidAfter": "2018-05-21T16:33:28Z",
"ValidBefore": "2018-05-24T16:33:28Z",
"CreateIndex": 5,
"ModifyIndex": 5
}

View File

@ -0,0 +1,18 @@
{
"ActiveRootID": "15:bf:3a:7d:ff:ea:c1:8c:46:67:6c:db:b8:81:18:36:ad:e5:d0:c7",
"Roots": [
{
"ID": "15:bf:3a:7d:ff:ea:c1:8c:46:67:6c:db:b8:81:18:36:ad:e5:d0:c7",
"Name": "Consul CA Root Cert",
"SerialNumber": 7,
"SigningKeyID": "31:66:3a:39:31:3a:63:61:3a:34:31:3a:38:66:3a:61:63:3a:36:37:3a:62:66:3a:35:39:3a:63:32:3a:66:61:3a:34:65:3a:37:35:3a:35:63:3a:64:38:3a:66:30:3a:35:35:3a:64:65:3a:62:65:3a:37:35:3a:62:38:3a:33:33:3a:33:31:3a:64:35:3a:32:34:3a:62:30:3a:30:34:3a:62:33:3a:65:38:3a:39:37:3a:35:62:3a:37:65",
"NotBefore": "2018-05-21T16:33:28Z",
"NotAfter": "2028-05-18T16:33:28Z",
"RootCert": "-----BEGIN CERTIFICATE-----\nMIICmDCCAj6gAwIBAgIBBzAKBggqhkjOPQQDAjAWMRQwEgYDVQQDEwtDb25zdWwg\nQ0EgNzAeFw0xODA1MjExNjMzMjhaFw0yODA1MTgxNjMzMjhaMBYxFDASBgNVBAMT\nC0NvbnN1bCBDQSA3MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAER0qlxjnRcMEr\niSGlH7G7dYU7lzBEmLUSMZkyBbClmyV8+e8WANemjn+PLnCr40If9cmpr7RnC9Qk\nGTaLnLiF16OCAXswggF3MA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/\nMGgGA1UdDgRhBF8xZjo5MTpjYTo0MTo4ZjphYzo2NzpiZjo1OTpjMjpmYTo0ZTo3\nNTo1YzpkODpmMDo1NTpkZTpiZTo3NTpiODozMzozMTpkNToyNDpiMDowNDpiMzpl\nODo5Nzo1Yjo3ZTBqBgNVHSMEYzBhgF8xZjo5MTpjYTo0MTo4ZjphYzo2NzpiZjo1\nOTpjMjpmYTo0ZTo3NTo1YzpkODpmMDo1NTpkZTpiZTo3NTpiODozMzozMTpkNToy\nNDpiMDowNDpiMzplODo5Nzo1Yjo3ZTA/BgNVHREEODA2hjRzcGlmZmU6Ly8xMjRk\nZjVhMC05ODIwLTc2YzMtOWFhOS02ZjYyMTY0YmExYzIuY29uc3VsMD0GA1UdHgEB\n/wQzMDGgLzAtgisxMjRkZjVhMC05ODIwLTc2YzMtOWFhOS02ZjYyMTY0YmExYzIu\nY29uc3VsMAoGCCqGSM49BAMCA0gAMEUCIQDzkkI7R+0U12a+zq2EQhP/n2mHmta+\nfs2hBxWIELGwTAIgLdO7RRw+z9nnxCIA6kNl//mIQb+PGItespiHZKAz74Q=\n-----END CERTIFICATE-----\n",
"IntermediateCerts": null,
"Active": true,
"CreateIndex": 8,
"ModifyIndex": 8
}
]
}

View File

@ -0,0 +1,17 @@
{
"ProxyServiceID": "web-proxy",
"TargetServiceID": "web",
"TargetServiceName": "web",
"ContentHash": "cffa5f4635b134b9",
"ExecMode": "daemon",
"Command": [
"/bin/consul",
"connect",
"proxy"
],
"Config": {
"bind_address": "127.0.0.1",
"bind_port": 20199,
"local_service_address": "127.0.0.1:8181"
}
}

View File

@ -0,0 +1,40 @@
{
"web": {
"Kind": "",
"ID": "web",
"Service": "web",
"Tags": [],
"Meta": {},
"Port": 8181,
"Address": "",
"EnableTagOverride": false,
"CreateIndex": 0,
"ModifyIndex": 0,
"ProxyDestination": "",
"Connect": {
"Proxy": {
"ExecMode": "daemon",
"Command": [
"/bin/consul",
"connect",
"proxy"
],
"Config": null
}
}
},
"web-proxy": {
"Kind": "connect-proxy",
"ID": "web-proxy",
"Service": "web-proxy",
"Tags": [],
"Meta": {},
"Port": 20199,
"Address": "",
"EnableTagOverride": false,
"CreateIndex": 0,
"ModifyIndex": 0,
"ProxyDestination": "web",
"Connect": null
}
}

View File

@ -0,0 +1,72 @@
${ location.pathname.slice(4).indexOf('-proxy') !== -1 ? `[]` :`
[
${
range(
env(
'CONSUL_PROXY_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_PROXY_MAX', 10)
) + parseInt(env('CONSUL_PROXY_MIN', 1))
)
)
).map((item, i) => `
{
"ID": "${fake.random.uuid()}",
${typeof location.search.ns !== 'undefined' ? `
"Namespace": "${location.search.ns}",
` : ``}
"Node": "node-${i}",
"Address": "${fake.internet.ip()}",
"Datacenter": "${location.search.dc}",
"TaggedAddresses": {
"lan": "${fake.internet.ip()}",
"wan": "${fake.internet.ip()}"
},
"NodeMeta": {
"consul-network-segment": ""
},
"ServiceConnect": {},
"ServiceKind": "connect-proxy",
"ServiceID": "${location.pathname.slice(4)}-with-id-proxy",
"ServiceName": "${location.pathname.slice(4)}-proxy",
"ServiceTags": ["Tag", "Another Tag"],
"ServiceAddress": "${fake.internet.ip()}",
"ServiceMeta": {},
"ServicePort": ${fake.random.number({min: 21000, max: 21255})},
"ServiceEnableTagOverride": false,
"ServiceProxy": {
"Expose": {
"Checks": true,
"Paths": [
${range(env('CONSUL_EXPOSED_COUNT', 3)).map((i) => `
{
"Path": "/${fake.lorem.words(fake.random.number({min: 1, max: 5})).split(' ').join('/')}${fake.random.boolean() ? fake.system.fileName() : ''}",
"Protocol": "${fake.helpers.randomize(['http', 'http2', 'grpc'])}",
"LocalPathPort": ${fake.random.number({min: 0, max: 65535})},
"ListenerPort": ${fake.random.number({min: 0, max: 65535})}
}
`)}
]
},
"DestinationServiceName": "${location.pathname.slice(4)}"
${ location.pathname.slice(4) === "service-0" ? `
,
"DestinationServiceID": "${location.pathname.slice(4)}-with-id",
"LocalServiceAddress": "${fake.internet.ip()}",
"LocalServicePort": ${fake.random.number({min: 0, max: 65535})}
`
: ``}
},
"ServiceProxyDestination": "${location.pathname.slice(4)}",
"ServiceWeights": {
"Passing": 1,
"Warning": 1
},
"CreateIndex": 11,
"ModifyIndex": 11
}
`)
}
]
`}

View File

@ -0,0 +1,13 @@
[
${
range(env('CONSUL_DATACENTER_COUNT', 10)).map((item, i) => {
if(i === 0) {
return `"dc1"`;
}
return `
"${fake.address.countryCode().toLowerCase()}_${ i % 2 ? "west" : "east"}-${i}"
`;
}
)
}
]

View File

@ -0,0 +1,8 @@
---
"*":
GET:
"*":
latency: ${ location.search.index ? env('CONSUL_LATENCY', 60000) : env('CONSUL_LATENCY', 0) }
headers:
response:
X-Consul-Index: ${ parseInt((location.search.index || 1)) + 1}

View File

@ -0,0 +1,115 @@
${
location.pathname.get(2) === 'intentions' && http.method === 'GET' ? `
[
${
range(
env(
'CONSUL_INTENTION_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_INTENTION_MAX', 10)
) + parseInt(env('CONSUL_INTENTION_MIN', 1))
)
)
).map(
function(item, i)
{
const legacy = fake.random.boolean();
return `
{
${legacy ? `
"ID": "${fake.random.uuid()}",
"Action": "${fake.helpers.randomize(['allow', 'deny'])}",
`:``}
"Description": "${fake.lorem.sentence()}",
"SourceNS": "default",
"SourceName": "${fake.hacker.noun()}-${i}",
"DestinationNS": "default",
"DestinationName": "${fake.hacker.noun()}",
"SourceType": "${fake.helpers.randomize(['consul', 'externaluri'])}",
${!legacy ? `
"Permissions": [
${range(
env(
'CONSUL_INTENTION_PERMISSION_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_INTENTION_PERMISSION_MAX', 10)
) + parseInt(env('CONSUL_INTENTION_PERMISSION_MIN', 1))
)
)
).map((item, i) => {
const headerCount = env(
'CONSUL_HEADER_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_HEADER_MAX', 3)
) + parseInt(env('CONSUL_HEADER_MIN', 1))
)
);
const path = fake.helpers.randomize(['PathExact', 'PathPrefix', 'PathRegex', '']);
return `
{
"Action": "${fake.helpers.randomize(['allow', 'deny'])}",
"HTTP": {
${path !== '' ? `
"${path}": "${path === 'PathRegex' ? `${fake.helpers.randomize(['^[0-9]{1,3}?$', '(\w+)\s(\w+)'])}` : `/${fake.lorem.words(fake.random.number({min: 1, max: 5})).split(' ').join('/')}${fake.random.boolean() ? fake.system.fileName() : ''}`}",
`:``}
${ fake.random.boolean() ? `
"Methods": [
${
fake.helpers.shuffle(
["GET", "POST", "PUT", "DELETE", "OPTIONS", "HEAD", "PATCH"]
).filter(item => fake.random.boolean()).map(item => `
"${item}"
`)
}
],
` : ``}
"Header": [
${range(headerCount).map(item => `
{
"Name": "X-${fake.hacker.noun().split(' ').map(item => `${item.substr(0, 1).toUpperCase()}${item.substr(1)}`).join('-')}",
${fake.random.boolean() ? `
"Invert": true,
` : ``}
${fake.helpers.randomize([
'"Present": true',
'"Exact": "abc"',
'"Prefix": "abc"',
'"Suffix": "xyz"',
'"Regex": "[abc]"'
])}
}
`)}
]
}
}
`})}
],
`:``}
"Precedence": ${i + 1},
${ fake.random.number({min: 1, max: 10}) > 2 ? `
"Meta": {
"external-source": "${fake.helpers.randomize(['kubernetes'])}"
},
` : `` }
"CreatedAt": "2018-05-21T16:41:27.977155457Z",
"UpdatedAt": "2018-05-21T16:41:27.977157724Z",
"CreateIndex": 11,
"ModifyIndex": 11
}
`;
}
)
}
]
` : location.pathname.get(2) === 'intentions' && http.method === 'POST' ? `
{
"ID": "${ location.pathname.get(3) }"
}
` : ``
}

View File

@ -0,0 +1,10 @@
{
"Provider": "consul",
"Config": {
"PrivateKey": null,
"RootCert": null,
"RotationPeriod": 7776000000000000
},
"CreateIndex": 5,
"ModifyIndex": 5
}

View File

@ -0,0 +1,18 @@
{
"ActiveRootID": "15:bf:3a:7d:ff:ea:c1:8c:46:67:6c:db:b8:81:18:36:ad:e5:d0:c7",
"Roots": [
{
"ID": "15:bf:3a:7d:ff:ea:c1:8c:46:67:6c:db:b8:81:18:36:ad:e5:d0:c7",
"Name": "Consul CA Root Cert",
"SerialNumber": 7,
"SigningKeyID": "31:66:3a:39:31:3a:63:61:3a:34:31:3a:38:66:3a:61:63:3a:36:37:3a:62:66:3a:35:39:3a:63:32:3a:66:61:3a:34:65:3a:37:35:3a:35:63:3a:64:38:3a:66:30:3a:35:35:3a:64:65:3a:62:65:3a:37:35:3a:62:38:3a:33:33:3a:33:31:3a:64:35:3a:32:34:3a:62:30:3a:30:34:3a:62:33:3a:65:38:3a:39:37:3a:35:62:3a:37:65",
"NotBefore": "2018-05-21T16:33:28Z",
"NotAfter": "2028-05-18T16:33:28Z",
"RootCert": "-----BEGIN CERTIFICATE-----\nMIICmDCCAj6gAwIBAgIBBzAKBggqhkjOPQQDAjAWMRQwEgYDVQQDEwtDb25zdWwg\nQ0EgNzAeFw0xODA1MjExNjMzMjhaFw0yODA1MTgxNjMzMjhaMBYxFDASBgNVBAMT\nC0NvbnN1bCBDQSA3MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAER0qlxjnRcMEr\niSGlH7G7dYU7lzBEmLUSMZkyBbClmyV8+e8WANemjn+PLnCr40If9cmpr7RnC9Qk\nGTaLnLiF16OCAXswggF3MA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/\nMGgGA1UdDgRhBF8xZjo5MTpjYTo0MTo4ZjphYzo2NzpiZjo1OTpjMjpmYTo0ZTo3\nNTo1YzpkODpmMDo1NTpkZTpiZTo3NTpiODozMzozMTpkNToyNDpiMDowNDpiMzpl\nODo5Nzo1Yjo3ZTBqBgNVHSMEYzBhgF8xZjo5MTpjYTo0MTo4ZjphYzo2NzpiZjo1\nOTpjMjpmYTo0ZTo3NTo1YzpkODpmMDo1NTpkZTpiZTo3NTpiODozMzozMTpkNToy\nNDpiMDowNDpiMzplODo5Nzo1Yjo3ZTA/BgNVHREEODA2hjRzcGlmZmU6Ly8xMjRk\nZjVhMC05ODIwLTc2YzMtOWFhOS02ZjYyMTY0YmExYzIuY29uc3VsMD0GA1UdHgEB\n/wQzMDGgLzAtgisxMjRkZjVhMC05ODIwLTc2YzMtOWFhOS02ZjYyMTY0YmExYzIu\nY29uc3VsMAoGCCqGSM49BAMCA0gAMEUCIQDzkkI7R+0U12a+zq2EQhP/n2mHmta+\nfs2hBxWIELGwTAIgLdO7RRw+z9nnxCIA6kNl//mIQb+PGItespiHZKAz74Q=\n-----END CERTIFICATE-----\n",
"IntermediateCerts": null,
"Active": true,
"CreateIndex": 8,
"ModifyIndex": 8
}
]
}

View File

@ -0,0 +1,91 @@
${range(1).map(item => {
const ID = location.pathname.get(3);
const legacy = ID.indexOf('%3A') === -1;
return `
{
"ID": "${legacy ? ID : ''}"
${ http.method !== "PUT" ? `
,"Description": "${fake.lorem.sentence()}",
"SourceNS": "default",
"SourceName": "${fake.hacker.noun()}",
"DestinationNS": "default",
"DestinationName": "${fake.hacker.noun()}",
"SourceType": "${fake.helpers.randomize(['consul', 'externaluri'])}",
${legacy ? `
"Action": "${fake.helpers.randomize(['allow', 'deny'])}",
`:``}
${!legacy ? `
"Permissions": [
${range(
env(
'CONSUL_INTENTION_PERMISSION_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_INTENTION_PERMISSION_MAX', 10)
) + parseInt(env('CONSUL_INTENTION_PERMISSION_MIN', 1))
)
)
).map((item, i) => {
const headerCount = env(
'CONSUL_HEADER_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_HEADER_MAX', 3)
) + parseInt(env('CONSUL_HEADER_MIN', 1))
)
);
const path = fake.helpers.randomize(['PathExact', 'PathPrefix', 'PathRegex', '']);
return `
{
"Action": "${fake.helpers.randomize(['allow', 'deny'])}",
"HTTP": {
${path !== '' ? `
"${path}": "${path === 'PathRegex' ? `${fake.helpers.randomize(['^[0-9]{1,3}?$', '(\w+)\s(\w+)'])}` : `/${fake.lorem.words(fake.random.number({min: 1, max: 5})).split(' ').join('/')}${fake.random.boolean() ? fake.system.fileName() : ''}`}",
`:``}
${ fake.random.boolean() ? `
"Methods": [
${
fake.helpers.shuffle(
["GET", "POST", "PUT", "DELETE", "OPTIONS", "HEAD", "PATCH"]
).filter(item => fake.random.boolean()).map(item => `
"${item}"
`)
}
],
` : ``}
"Header": [
${range(headerCount).map(item => `
{
"Name": "X-${fake.hacker.noun().split(' ').map(item => `${item.substr(0, 1).toUpperCase()}${item.substr(1)}`).join('-')}",
${fake.random.boolean() ? `
"Invert": true,
` : ``}
${fake.helpers.randomize([
'"Present": true',
'"Exact": "abc"',
'"Prefix": "abc"',
'"Suffix": "xyz"',
'"Regex": "[abc]"'
])}
}
`)}
]
}
}
`})}
],
`:``}
"Precedence": ${fake.random.number({min: 1, max: 100})},
${ !legacy && fake.random.number({min: 1, max: 10}) > 2 ? `
"Meta": {
"external-source": "${fake.helpers.randomize(['kubernetes'])}"
},
` : `` }
"CreatedAt": "2018-05-21T16:41:27.977155457Z",
"UpdatedAt": "2018-05-21T16:41:27.977157724Z",
"CreateIndex": 11,
"ModifyIndex": 11
` : ``}
}
`})}

View File

@ -0,0 +1,4 @@
{
"Allowed": true
}

View File

@ -0,0 +1,93 @@
${range(1).map(item => {
const ID = fake.random.uuid();
const legacy = ID.indexOf('%3A') === -1;
const source = location.search.source.split('/');
const destination = location.search.destination.split('/');
return `
{
"ID": "${legacy ? ID : ''}"
${ http.method !== "PUT" ? `
,"Description": "${fake.lorem.sentence()}",
"SourceNS": "${source[0]}",
"SourceName": "${source[1]}",
"DestinationNS": "${destination[0]}",
"DestinationName": "${destination[1]}",
"SourceType": "${fake.helpers.randomize(['consul', 'externaluri'])}",
${legacy ? `
"Action": "${fake.helpers.randomize(['allow', 'deny'])}",
`:``}
${!legacy ? `
"Permissions": [
${range(
env(
'CONSUL_INTENTION_PERMISSION_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_INTENTION_PERMISSION_MAX', 10)
) + parseInt(env('CONSUL_INTENTION_PERMISSION_MIN', 1))
)
)
).map((item, i) => {
const headerCount = env(
'CONSUL_HEADER_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_HEADER_MAX', 3)
) + parseInt(env('CONSUL_HEADER_MIN', 1))
)
);
const path = fake.helpers.randomize(['PathExact', 'PathPrefix', 'PathRegex', '']);
return `
{
"Action": "${fake.helpers.randomize(['allow', 'deny'])}",
"HTTP": {
${path !== '' ? `
"${path}": "${path === 'PathRegex' ? `${fake.helpers.randomize(['^[0-9]{1,3}?$', '(\w+)\s(\w+)'])}` : `/${fake.lorem.words(fake.random.number({min: 1, max: 5})).split(' ').join('/')}${fake.random.boolean() ? fake.system.fileName() : ''}`}",
`:``}
${ fake.random.boolean() ? `
"Methods": [
${
fake.helpers.shuffle(
["GET", "POST", "PUT", "DELETE", "OPTIONS", "HEAD", "PATCH"]
).filter(item => fake.random.boolean()).map(item => `
"${item}"
`)
}
],
` : ``}
"Header": [
${range(headerCount).map(item => `
{
"Name": "X-${fake.hacker.noun().split(' ').map(item => `${item.substr(0, 1).toUpperCase()}${item.substr(1)}`).join('-')}",
${fake.random.boolean() ? `
"Invert": true,
` : ``}
${fake.helpers.randomize([
'"Present": true',
'"Exact": "abc"',
'"Prefix": "abc"',
'"Suffix": "xyz"',
'"Regex": "[abc]"'
])}
}
`)}
]
}
}
`})}
],
`:``}
"Precedence": ${fake.random.number({min: 1, max: 100})},
${ !legacy && fake.random.number({min: 1, max: 10}) > 2 ? `
"Meta": {
"external-source": "${fake.helpers.randomize(['kubernetes'])}"
},
` : `` }
"CreatedAt": "2018-05-21T16:41:27.977155457Z",
"UpdatedAt": "2018-05-21T16:41:27.977157724Z",
"CreateIndex": 11,
"ModifyIndex": 11
` : ``}
}
`})}

View File

@ -0,0 +1,38 @@
{
"db": [
{
"ID": "ed16f6a6-d863-1bec-af45-96bbdcbe02be",
"Description": "",
"SourceNS": "default",
"SourceName": "billing",
"DestinationNS": "default",
"DestinationName": "db",
"SourceType": "consul",
"Action": "deny",
"DefaultAddr": "",
"DefaultPort": 0,
"Meta": {},
"CreatedAt": "2018-05-21T16:41:33.296693825Z",
"UpdatedAt": "2018-05-21T16:41:33.296694288Z",
"CreateIndex": 12,
"ModifyIndex": 12
},
{
"ID": "e9ebc19f-d481-42b1-4871-4d298d3acd5c",
"Description": "",
"SourceNS": "default",
"SourceName": "web",
"DestinationNS": "default",
"DestinationName": "db",
"SourceType": "consul",
"Action": "allow",
"DefaultAddr": "",
"DefaultPort": 0,
"Meta": {},
"CreatedAt": "2018-05-21T16:41:27.977155457Z",
"UpdatedAt": "2018-05-21T16:41:27.977157724Z",
"CreateIndex": 11,
"ModifyIndex": 11
}
]
}

View File

@ -0,0 +1,10 @@
---
"*":
GET:
"*":
headers:
response:
X-Consul-Index: ${ parseInt((location.search.index || 1)) + 1}
index:
"*":
latency: ${ location.search.index ? env('CONSUL_LATENCY', 60000) : env('CONSUL_LATENCY', 0) }

View File

@ -0,0 +1,30 @@
[
${
range(
env(
'CONSUL_NODE_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_NODE_MAX', 10)
) + parseInt(env('CONSUL_NODE_MIN', 1))
)
)
).map(
function(item, i)
{
return `
{
"Node":"node-${i}",
"Segment":"",
"Coord":{
"Vec":[${range(7).map((item, i) => fake.random.number())}],
"Error":1.5,
"Adjustment":0,
"Height":0.0000${fake.random.number()}
}
}
`;
}
)
}
]

View File

@ -0,0 +1,9 @@
---
"*":
GET:
"*":
latency: ${ location.search.index ? env('CONSUL_LATENCY', 60000) : env('CONSUL_LATENCY', 0) }
headers:
response:
X-Consul-Index: ${ parseInt((location.search.index || 1)) + 1}

View File

@ -0,0 +1,352 @@
${
[1].map(() => {
const namespaces = ['default'];
const ns = location.search.ns || 'default';
const dc = location.search.dc;
const service = location.pathname.get(2);
const routeCount = env(
'CONSUL_ROUTE_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_ROUTE_MAX', 10)
) + parseInt(env('CONSUL_ROUTE_MIN', 1))
)
);
const headerCount = env(
'CONSUL_HEADER_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_HEADER_MAX', 3)
) + parseInt(env('CONSUL_HEADER_MIN', 1))
)
);
const queryParamCount = env(
'CONSUL_QUERYPARAM_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_QUERYPARAM_MAX', 3)
) + parseInt(env('CONSUL_QUERYPARAM_MIN', 1))
)
);
const resolverCount = env(
'CONSUL_RESOLVER_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_RESOLVER_MAX', 10)
) + parseInt(env('CONSUL_RESOLVER_MIN', 1))
)
);
const redirectCount = env(
'CONSUL_REDIRECT_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_REDIRECT_MAX', resolverCount)
) + parseInt(env('CONSUL_REDIRECT_MIN', 0))
)
);
const splitterCount = env(
'CONSUL_SPLITTER_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_SPLITTER_MAX', 5)
) + parseInt(env('CONSUL_SPLITTER_MIN', 1))
)
);
const splitCount = env(
'CONSUL_SPLIT_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_SPLIT_MAX', 10)
) + parseInt(env('CONSUL_SPLIT_MIN', 1))
)
);
// make some resolvers
let resolvers = range(
resolverCount
).map(() => {
const service = fake.hacker.noun().split(' ').join('-');
return {
ServiceName: service,
Name: `${service}.${ns}.${dc}`,
Subsets: range(
env(
'CONSUL_SUBSET_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_SUBSET_MAX', 3)
) + parseInt(env('CONSUL_SUBSET_MIN', 1))
)
)
).map((item) => `v${item + 1}`)
};
});
// make some redirects
const redirects = range(
redirectCount
).map((item, i) => {
const service = resolvers[i].ServiceName;
return {
ServiceName: service,
Name: `${service}.${ns}.redirect-${dc}`,
Subsets: []
};
});
// make some resolver targets with possible subsets
let resolverTargets = resolvers.reduce(
function(prev, resolver) {
const targets = [`${resolver.Name}`];
return prev.concat(targets.concat(
resolver.Subsets.map(
function(item) {
return `${item}.${targets[0]}`
}
)
).map(
(item) => `resolver:${item}`
));
},
[]
);
const redirectTargets = redirects.map(
function(item) {
return `resolver:${item.Name}`;
}
);
resolverTargets = resolverTargets.concat(redirectTargets);
resolvers = resolvers.concat(redirects);
const splitters = range(
splitterCount
).map(() => ({
Name: `${service}-${fake.hacker.noun()}.${ns}`,
Splits: range(
splitCount
).map((item, i, arr) => ({
"Weight": 100 / arr.length,
"NextNode": fake.helpers.randomize(resolverTargets)
}))
}));
const splitterTargets = splitters.map(
function(item) {
return `splitter:${item.Name}`;
}
);
const nextNodes = resolverTargets.concat(splitterTargets);
return `
{
"Chain": {
"ServiceName": "${service}",
"Namespace": "${ns}",
"Datacenter": "${dc}",
"Protocol": "http",
"StartNode": "router:${service}",
"Nodes": {
"router:${service}": {
"Type": "router",
"Name": "${service}",
"Routes": [
${
range(
routeCount
).map((item, i) => {
const path = fake.helpers.randomize(['PathExact', 'PathPrefix', 'PathRegex', '']);
const splitter = fake.helpers.randomize(splitters);
const nextNode = fake.helpers.randomize(nextNodes);
return `
{
"NextNode": "${nextNode}",
"Definition": {
"Match": {
"HTTP": {
${ path !== '' ? `
"${path}": "${path === 'PathRegex' ? `${fake.helpers.randomize(['^[0-9]{1,3}?$', '(\w+)\s(\w+)'])}` : `/${fake.lorem.words(fake.random.number({min: 1, max: 5})).split(' ').join('/')}${fake.random.boolean() ? fake.system.fileName() : ''}`}"
` : `"": ""`}
${ fake.random.boolean() ? `
,"Header": [
${
range(
headerCount
).map(item => `
{
"Name": "X-${fake.hacker.noun().split(' ').map(item => `${item.substr(0, 1).toUpperCase()}${item.substr(1)}`).join('-')}",
${fake.random.boolean() ? `
"Invert": true,
` : ``
}
${fake.helpers.randomize([
'"Present": true',
'"Exact": true',
'"Prefix": "abc"',
'"Suffix": "xyz"',
'"Regex": "[abc]"'
])}
}
`)}
]
` : ``}
${ fake.random.boolean() ? `
,"QueryParam": [
${
range(
queryParamCount
).map(item => `
{
"Name": "${fake.hacker.noun().split(' ').join('-')}",
${fake.helpers.randomize([
'"Present": true',
'"Exact": true',
'"Prefix": "abc"',
'"Suffix": "xyz"',
'"Regex": "[abc]"'
])}
}
`)}
]
` : ``}
${ fake.random.boolean() ? `
,"Methods": [
${
fake.helpers.shuffle(
["GET", "POST", "PUT", "DELETE", "OPTIONS", "HEAD", "PATCH"]
).filter(item => fake.random.boolean()).map(item => `
"${item}"
`)
}
]
` : ``}
}
},
"Destination": {
"Service": "${nextNode}",
"PrefixRewrite": "/"
}
}
}
`;})}
]
},
${resolvers.map((resolver) => {
const failoverCount = env(
'CONSUL_FAILOVER_COUNT',
fake.helpers.randomize([0, 0, 0, 0, 0, 1, 2, 3])
);
const failover = ({
Datacenter: `${resolver.Name.replace(`.${dc}`, `.fail-${dc}`).replace(`.redirect-${dc}`, `.fail-${dc}`)}`,
Namespace: `${resolver.Name.replace(`.${ns}.`, `.fail-${ns}.`).replace(`.redirect-${ns}.`, `.fail-${ns}.`)}`,
})[env('CONSUL_FAILOVER_TYPE', 'Datacenter')];
return `
"resolver:${resolver.Name}": {
"Type": "resolver",
"Name": "${resolver.Name}",
"Resolver": {
"ConnectTimeout": "5s",
${failoverCount > 0 ? `
"Failover": {
"Targets": [
${range(failoverCount).map(item => `
"${failover.replace('fail-', `fail-${item + 1}-`)}"
`)}
]
},
` : `` }
"Target": "${resolver.Name}"
}
}${resolver.Subsets.length > 0 ? ',' : ''}
${resolver.Subsets.map((subset) => {
const id = `${subset}.${resolver.Name}`;
const failover = ({
Datacenter: `${subset}.${resolver.Name.replace(`.${dc}`, `.fail-${dc}`)}`,
Namespace: `${subset}.${resolver.Name.replace(`.${ns}.`, `.fail-${ns}.`)}`,
})[env('CONSUL_FAILOVER_TYPE', 'Datacenter')];
return `
"resolver:${id}": {
"Type": "resolver",
"Name": "${id}",
"Resolver": {
"ConnectTimeout": "5s",
${failoverCount > 0 ? `
"Failover": {
"Targets": [
${range(failoverCount).map(item => `
"${failover.replace('fail-', `fail-${item + 1}-`)}"
`)}
]
},
` : `` }
"Target": "${id}"
}
}
`;
})}
`})},
${splitters.map((item, i) => `
"splitter:${item.Name}": {
"Type": "splitter",
"Name": "${item.Name}",
"Splits": [
${item.Splits.map(item => `
{
"Weight": ${item.Weight},
"NextNode": "${item.NextNode}"
}
`)}
]
}
`)}
},
"Targets": {
${resolvers.map(item => {
const uuid = fake.random.uuid();
const domain = 'consul';
const name = `${item.Name}.internal.${uuid}.${domain}`;
return `
"${item.Name}": {
"ID": "${item.Name}",
"Service": "${item.ServiceName}",
"Namespace": "${ns}",
"Datacenter": "${dc}",
"MeshGateway": {},
"SNI": "${name}",
"Name": "${name}"
}${item.Subsets.length > 0 ? ',' : ''}
${item.Subsets.map(ktem => {
const id = `${ktem}.${item.Name}`;
const name = `${id}.internal.${uuid}.${domain}`;
return `
"${id}": {
"ID": "${id}",
"Service": "${item.ServiceName}",
"ServiceSubset": "${ktem}",
"Namespace": "${ns}",
"Datacenter": "${dc}",
"MeshGateway": {
},
"Subset": {
"Filter": "Service.Meta.value == ${ktem}"
},
"SNI": "${name}",
"Name": "${name}"
}
`})}
`})}
}
}
}
`})}

View File

@ -0,0 +1 @@
{"Chain":{"ServiceName":"virtual-admin-1","Namespace":"default","Datacenter":"dc-gcp","Protocol":"http","StartNode":"router:virtual-admin-1","Nodes":{"resolver:virtual-admin-1.default.dc-gcp":{"Type":"resolver","Name":"virtual-admin-1.default.dc-gcp","Resolver":{"ConnectTimeout":"5s","Default":true,"Target":"virtual-admin-1.default.dc-gcp"}},"resolver:web.default.dc-aws":{"Type":"resolver","Name":"web.default.dc-aws","Resolver":{"ConnectTimeout":"15s","Target":"web.default.dc-aws","Failover":{"Targets":["web.default.dc-gcp"]}}},"resolver:web.default.dc-gcp":{"Type":"resolver","Name":"web.default.dc-gcp","Resolver":{"ConnectTimeout":"15s","Target":"web.default.dc-gcp","Failover":{"Targets":["web.default.dc-aws"]}}},"router:virtual-admin-1":{"Type":"router","Name":"virtual-admin-1","Routes":[{"Definition":{"Match":{"HTTP":{"PathPrefix":"/login"}},"Destination":{"Service":"login","PrefixRewrite":"/"}},"NextNode":"splitter:login.default"},{"Definition":{"Destination":{"Service":"global-admin"}},"NextNode":"splitter:global-admin.default"},{"Definition":{"Match":{"HTTP":{"PathPrefix":"/"}},"Destination":{"Service":"virtual-admin-1"}},"NextNode":"resolver:virtual-admin-1.default.dc-gcp"}]},"splitter:global-admin.default":{"Type":"splitter","Name":"global-admin.default","Splits":[{"Weight":50,"NextNode":"resolver:web.default.dc-aws"},{"Weight":50,"NextNode":"resolver:web.default.dc-gcp"}]},"splitter:login.default":{"Type":"splitter","Name":"login.default","Splits":[{"Weight":50,"NextNode":"resolver:web.default.dc-gcp"},{"Weight":50,"NextNode":"resolver:web.default.dc-aws"}]}},"Targets":{"virtual-admin-1.default.dc-gcp":{"ID":"virtual-admin-1.default.dc-gcp","Service":"virtual-admin-1","Namespace":"default","Datacenter":"dc-gcp","MeshGateway":{},"Subset":{},"SNI":"virtual-admin-1.default.dc-gcp.internal.ede9daf4-b641-3954-5a52-15f4fd666f6e.consul","Name":"virtual-admin-1.default.dc-gcp.internal.ede9daf4-b641-3954-5a52-15f4fd666f6e.consul"},"web.default.dc-aws":{"ID":"web.default.dc-aws","Service":"web","Namespace":"default","Datacenter":"dc-aws","MeshGateway":{"Mode":"local"},"Subset":{},"SNI":"web.default.dc-aws.internal.ede9daf4-b641-3954-5a52-15f4fd666f6e.consul","Name":"web.default.dc-aws.internal.ede9daf4-b641-3954-5a52-15f4fd666f6e.consul"},"web.default.dc-gcp":{"ID":"web.default.dc-gcp","Service":"web","Namespace":"default","Datacenter":"dc-gcp","MeshGateway":{},"Subset":{},"SNI":"web.default.dc-gcp.internal.ede9daf4-b641-3954-5a52-15f4fd666f6e.consul","Name":"web.default.dc-gcp.internal.ede9daf4-b641-3954-5a52-15f4fd666f6e.consul"}}}}

View File

@ -0,0 +1 @@
{"Chain":{"ServiceName":"virtual-admin-2","Namespace":"default","Datacenter":"dc-gcp","Protocol":"http","StartNode":"splitter:virtual-admin-2.default","Nodes":{"resolver:web.default.dc-aws":{"Type":"resolver","Name":"web.default.dc-aws","Resolver":{"ConnectTimeout":"15s","Target":"web.default.dc-aws","Failover":{"Targets":["web.default.dc-gcp"]}}},"resolver:web.default.dc-gcp":{"Type":"resolver","Name":"web.default.dc-gcp","Resolver":{"ConnectTimeout":"15s","Target":"web.default.dc-gcp","Failover":{"Targets":["web.default.dc-aws"]}}},"splitter:virtual-admin-2.default":{"Type":"splitter","Name":"virtual-admin-2.default","Splits":[{"Weight":50,"NextNode":"resolver:web.default.dc-gcp"},{"Weight":50,"NextNode":"resolver:web.default.dc-aws"}]}},"Targets":{"web.default.dc-aws":{"ID":"web.default.dc-aws","Service":"web","Namespace":"default","Datacenter":"dc-aws","MeshGateway":{"Mode":"local"},"Subset":{},"SNI":"web.default.dc-aws.internal.ede9daf4-b641-3954-5a52-15f4fd666f6e.consul","Name":"web.default.dc-aws.internal.ede9daf4-b641-3954-5a52-15f4fd666f6e.consul"},"web.default.dc-gcp":{"ID":"web.default.dc-gcp","Service":"web","Namespace":"default","Datacenter":"dc-gcp","MeshGateway":{},"Subset":{},"SNI":"web.default.dc-gcp.internal.ede9daf4-b641-3954-5a52-15f4fd666f6e.consul","Name":"web.default.dc-gcp.internal.ede9daf4-b641-3954-5a52-15f4fd666f6e.consul"}}}}

View File

@ -0,0 +1 @@
{"Chain":{"ServiceName":"virtual-admin-3","Namespace":"default","Datacenter":"dc-gcp","Protocol":"http","StartNode":"splitter:virtual-admin-3.default","Nodes":{"resolver:web.default.dc-aws":{"Type":"resolver","Name":"web.default.dc-aws","Resolver":{"ConnectTimeout":"15s","Target":"web.default.dc-aws"}},"resolver:web.default.dc-gcp":{"Type":"resolver","Name":"web.default.dc-gcp","Resolver":{"ConnectTimeout":"15s","Target":"web.default.dc-gcp"}},"splitter:virtual-admin-3.default":{"Type":"splitter","Name":"virtual-admin-3.default","Splits":[{"Weight":50,"NextNode":"resolver:web.default.dc-gcp"},{"Weight":50,"NextNode":"resolver:web.default.dc-aws"}]}},"Targets":{"web.default.dc-aws":{"ID":"web.default.dc-aws","Service":"web","Namespace":"default","Datacenter":"dc-aws","MeshGateway":{"Mode":"local"},"Subset":{},"SNI":"web.default.dc-aws.internal.ede9daf4-b641-3954-5a52-15f4fd666f6e.consul","Name":"web.default.dc-aws.internal.ede9daf4-b641-3954-5a52-15f4fd666f6e.consul"},"web.default.dc-gcp":{"ID":"web.default.dc-gcp","Service":"web","Namespace":"default","Datacenter":"dc-gcp","MeshGateway":{},"Subset":{},"SNI":"web.default.dc-gcp.internal.ede9daf4-b641-3954-5a52-15f4fd666f6e.consul","Name":"web.default.dc-gcp.internal.ede9daf4-b641-3954-5a52-15f4fd666f6e.consul"}}}}

View File

@ -0,0 +1 @@
{"Chain":{"ServiceName":"virtual-admin-4","Namespace":"default","Datacenter":"dc1","Protocol":"http","StartNode":"router:virtual-admin-4","Nodes":{"resolver:admin.default.dc1":{"Type":"resolver","Name":"admin.default.dc1","Resolver":{"ConnectTimeout":"5s","Default":true,"Target":"admin.default.dc1"}},"resolver:admin.default.dc2":{"Type":"resolver","Name":"admin.default.dc2","Resolver":{"ConnectTimeout":"5s","Default":true,"Target":"admin.default.dc2"}},"resolver:login.default.dc1":{"Type":"resolver","Name":"login.default.dc1","Resolver":{"ConnectTimeout":"5s","Default":true,"Target":"login.default.dc1"}},"resolver:virtual-admin-4.default.dc1":{"Type":"resolver","Name":"virtual-admin-4.default.dc1","Resolver":{"ConnectTimeout":"5s","Default":true,"Target":"virtual-admin-4.default.dc1"}},"router:virtual-admin-4":{"Type":"router","Name":"virtual-admin-4","Routes":[{"Definition":{"Match":{"HTTP":{"PathPrefix":"/login"}},"Destination":{"Service":"login","PrefixRewrite":"/"}},"NextNode":"resolver:login.default.dc1"},{"Definition":{"Destination":{"Service":"global-admin"}},"NextNode":"splitter:global-admin.default"},{"Definition":{"Match":{"HTTP":{"PathPrefix":"/"}},"Destination":{"Service":"virtual-admin-4"}},"NextNode":"resolver:virtual-admin-4.default.dc1"}]},"splitter:global-admin.default":{"Type":"splitter","Name":"global-admin.default","Splits":[{"Weight":50,"NextNode":"resolver:admin.default.dc1"},{"Weight":50,"NextNode":"resolver:admin.default.dc2"}]}},"Targets":{"admin.default.dc1":{"ID":"admin.default.dc1","Service":"admin","Namespace":"default","Datacenter":"dc1","MeshGateway":{},"Subset":{},"SNI":"admin.default.dc1.internal.6818c189-1048-8114-7d9f-ae248864b349.consul","Name":"admin.default.dc1.internal.6818c189-1048-8114-7d9f-ae248864b349.consul"},"admin.default.dc2":{"ID":"admin.default.dc2","Service":"admin","Namespace":"default","Datacenter":"dc2","MeshGateway":{"Mode":"local"},"Subset":{},"SNI":"admin.default.dc2.internal.6818c189-1048-8114-7d9f-ae248864b349.consul","Name":"admin.default.dc2.internal.6818c189-1048-8114-7d9f-ae248864b349.consul"},"login.default.dc1":{"ID":"login.default.dc1","Service":"login","Namespace":"default","Datacenter":"dc1","MeshGateway":{},"Subset":{},"SNI":"login.default.dc1.internal.6818c189-1048-8114-7d9f-ae248864b349.consul","Name":"login.default.dc1.internal.6818c189-1048-8114-7d9f-ae248864b349.consul"},"virtual-admin-4.default.dc1":{"ID":"virtual-admin-4.default.dc1","Service":"virtual-admin-4","Namespace":"default","Datacenter":"dc1","MeshGateway":{},"Subset":{},"SNI":"virtual-admin-4.default.dc1.internal.6818c189-1048-8114-7d9f-ae248864b349.consul","Name":"virtual-admin-4.default.dc1.internal.6818c189-1048-8114-7d9f-ae248864b349.consul"}}}}

View File

@ -0,0 +1 @@
{"Chain":{"ServiceName":"virtual-admin-5","Namespace":"default","Datacenter":"dc2","Protocol":"http","StartNode":"router:virtual-admin-5","Nodes":{"resolver:admin.default.dc1":{"Type":"resolver","Name":"admin.default.dc1","Resolver":{"ConnectTimeout":"5s","Default":true,"Target":"admin.default.dc1"}},"resolver:admin.default.dc2":{"Type":"resolver","Name":"admin.default.dc2","Resolver":{"ConnectTimeout":"5s","Default":true,"Target":"admin.default.dc2"}},"resolver:login.default.dc2":{"Type":"resolver","Name":"login.default.dc2","Resolver":{"ConnectTimeout":"5s","Default":true,"Target":"login.default.dc2"}},"resolver:virtual-admin-5.default.dc2":{"Type":"resolver","Name":"virtual-admin-5.default.dc2","Resolver":{"ConnectTimeout":"5s","Default":true,"Target":"virtual-admin-5.default.dc2"}},"router:virtual-admin-5":{"Type":"router","Name":"virtual-admin-5","Routes":[{"Definition":{"Match":{"HTTP":{"PathPrefix":"/login"}},"Destination":{"Service":"login","PrefixRewrite":"/"}},"NextNode":"resolver:login.default.dc2"},{"Definition":{"Match":{"HTTP":{"PathPrefix":"/"}},"Destination":{"Service":"global-admin"}},"NextNode":"splitter:global-admin.default"},{"Definition":{"Match":{"HTTP":{"PathPrefix":"/"}},"Destination":{"Service":"virtual-admin-5"}},"NextNode":"resolver:virtual-admin-5.default.dc2"}]},"splitter:global-admin.default":{"Type":"splitter","Name":"global-admin.default","Splits":[{"Weight":50,"NextNode":"resolver:admin.default.dc1"},{"Weight":50,"NextNode":"resolver:admin.default.dc2"}]}},"Targets":{"admin.default.dc1":{"ID":"admin.default.dc1","Service":"admin","Namespace":"default","Datacenter":"dc1","MeshGateway":{"Mode":"local"},"Subset":{},"SNI":"admin.default.dc1.internal.6818c189-1048-8114-7d9f-ae248864b349.consul","Name":"admin.default.dc1.internal.6818c189-1048-8114-7d9f-ae248864b349.consul"},"admin.default.dc2":{"ID":"admin.default.dc2","Service":"admin","Namespace":"default","Datacenter":"dc2","MeshGateway":{},"Subset":{},"SNI":"admin.default.dc2.internal.6818c189-1048-8114-7d9f-ae248864b349.consul","Name":"admin.default.dc2.internal.6818c189-1048-8114-7d9f-ae248864b349.consul"},"login.default.dc2":{"ID":"login.default.dc2","Service":"login","Namespace":"default","Datacenter":"dc2","MeshGateway":{},"Subset":{},"SNI":"login.default.dc2.internal.6818c189-1048-8114-7d9f-ae248864b349.consul","Name":"login.default.dc2.internal.6818c189-1048-8114-7d9f-ae248864b349.consul"},"virtual-admin-5.default.dc2":{"ID":"virtual-admin-5.default.dc2","Service":"virtual-admin-5","Namespace":"default","Datacenter":"dc2","MeshGateway":{},"Subset":{},"SNI":"virtual-admin-5.default.dc2.internal.6818c189-1048-8114-7d9f-ae248864b349.consul","Name":"virtual-admin-5.default.dc2.internal.6818c189-1048-8114-7d9f-ae248864b349.consul"}}}}

View File

@ -0,0 +1,8 @@
---
"*":
GET:
"*":
latency: ${ location.search.index ? env('CONSUL_LATENCY', 60000) : env('CONSUL_LATENCY', 0) }
headers:
response:
X-Consul-Index: ${ parseInt((location.search.index || 1)) + 1}

View File

@ -0,0 +1,160 @@
[
${
range(
env(
'CONSUL_NODE_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_NODE_MAX', 10)
) + parseInt(env('CONSUL_NODE_MIN', 1))
)
)
).map(
function(item, i)
{
const node = `node-${i}`;
const service = location.pathname.slice(4);
const ip = fake.internet.ip();
const proxy = service.indexOf('-proxy')
const sidecar = service.indexOf('-sidecar-proxy')
const id = (proxy !== -1 ? service.slice(0, -6) + '-with-id-proxy' : service + '-with-id');
let kind = '';
switch(true) {
case service.endsWith('-mesh-gateway'):
kind = 'mesh-gateway';
break;
case service.endsWith('-terminating-gateway'):
kind = 'terminating-gateway';
break;
case service.endsWith('-ingress-gateway'):
kind = 'ingress-gateway';
break;
case service.endsWith('-proxy'):
kind = 'connect-proxy';
break;
}
return `
{
"Node":{
"ID":"7037e928-d9e8-3b58-4712-6f5ded209002",
"Node":"${node}",
"Address":"${ip}",
"Datacenter":"dc1",
"TaggedAddresses":{"lan":"${ip}","wan":"${ip}"},
"Meta":{"${service}-network-segment":""},
"CreateIndex":5,
"ModifyIndex":6
},
"Service":{
"ID": "${ i === 0 ? id : fake.helpers.randomize([service, service + '-ID'])}",
"Service":"${service}",
${typeof location.search.ns !== 'undefined' ? `
"Namespace": "${location.search.ns}",
` : ``}
"Tags":[
${
range(
env(
'CONSUL_TAG_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_TAG_MAX', 10)
) + parseInt(env('CONSUL_TAG_MIN', 1))
)
)
).map(
function(item, i)
{
return `"${fake.hacker.noun()}"`;
}
)
}
],
${ fake.random.number({min: 1, max: 10}) > 2 ? `
"Meta": {
"consul-dashboard-url": "${fake.internet.protocol()}://${fake.internet.domainName()}/?id={{Service}}",
"external-source": "${fake.helpers.randomize(['consul', 'nomad', 'terraform', 'kubernetes', 'aws', ''])}"
},
` : `` }
"Address":"${fake.internet.ip()}",
"Port":${fake.random.number({min: 0, max: 65535})},
${kind !== '' ? `
"Kind": "${kind}",
` : `` }
"Proxy": {
${proxy !== -1 && sidecar === -1 ? `
"DestinationServiceName": "${service.substr(0, proxy)}",
` : ``}
${sidecar !== -1 ? `
"DestinationServiceName": "${service.substr(0, sidecar)}",
"DestinationServiceID": "${service.substr(0, sidecar)}-ID",
"LocalServiceAddress": "${fake.internet.ip()}",
"LocalServicePort": ${fake.random.number({min: 0, max: 65535})},
` : ``}
${proxy !== -1 ? `
"Expose": {
"Checks": true,
"Paths": [
${range(env('CONSUL_EXPOSED_COUNT', 3)).map((i) => `
{
"Path": "/${fake.lorem.words(fake.random.number({min: 1, max: 5})).split(' ').join('/')}${fake.random.boolean() ? fake.system.fileName() : ''}",
"Protocol": "${fake.helpers.randomize(['http', 'http2', 'grpc'])}",
"LocalPathPort": ${fake.random.number({min: 0, max: 65535})},
"ListenerPort": ${fake.random.number({min: 0, max: 65535})}
}
`)}
]
},
"Upstreams": [
${range(env('CONSUL_UPSTREAM_COUNT', 10)).map((item, j) => `
{
"Datacenter": "${fake.address.countryCode().toLowerCase()} ${ i % 2 ? "west" : "east"}-${j}",
"DestinationName": "${fake.hacker.noun()}",
"DestinationNamespace": "${fake.hacker.noun()}",
"DestinationType": "${fake.helpers.randomize(['service', 'prepared_query'])}",
"LocalBindAddress": "${fake.internet.ip()}",
"LocalBindPort": ${fake.random.number({min: 0, max: 65535})}
}
`)}
]
` : ``}
},
"ProxyDestination": "",
"EnableTagOverride":false,
"CreateIndex":5,
"ModifyIndex":5
},
"Checks":[
${
range(env('CONSUL_CHECK_COUNT', 10)).map(
function(item, j) {
const passing = i > 7 || j > fake.random.number(4);
const id = fake.helpers.randomize([service, '']);
return `
{
"Node":"${node}",
"CheckID":"${fake.hacker.noun()}Health",
"Name":"${fake.hacker.noun()} Status",
"Type": "${j === 0 ? 'ttl' : (j === 1 ? 'http' : fake.helpers.randomize(['script', 'http', 'tcp', 'ttl', 'docker', 'grpc', 'alias']))}",
"Status":"${j < 2 ? 'critical' : (passing ? "passing" : fake.helpers.randomize(['warning', 'critical']))}",
"Notes":"${fake.lorem.paragraph()}",
"Output":"${fake.internet.ipv6()} ${fake.internet.protocol()}://${fake.internet.userName()}:${fake.internet.password()}@${fake.internet.domainName()} ${fake.internet.userAgent()}",
"ServiceID":"${j < 2 ? service : id}",
"ServiceName":"",
"ServiceTags":["Tag"],
"Definition":{},
"CreateIndex":5,
"ModifyIndex":5
}
`;
}
)
}
]
}
`;
}
)
}
]

View File

@ -0,0 +1,34 @@
[
{
"Resource": "acl",
"Access": "read",
"Allow": false
},
{
"Resource": "acl",
"Access": "write",
"Allow": false
},
{
"Resource": "operator",
"Access": "read",
"Allow": true
},
{
"Resource": "operator",
"Access": "write",
"Allow": true
},
{
"Resource": "service",
"Segment": "web",
"Access": "read",
"Allow": true
},
{
"Resource": "service",
"Segment": "web",
"Access": "write",
"Allow": true
}
]

View File

@ -0,0 +1,8 @@
---
"*":
GET:
"*":
latency: ${ location.search.index ? env('CONSUL_LATENCY', 60000) : env('CONSUL_LATENCY', 0) }
headers:
response:
X-Consul-Index: ${ parseInt((location.search.index || 1)) + 1}

View File

@ -0,0 +1,8 @@
---
"*":
GET:
"*":
latency: ${ location.search.index ? env('CONSUL_LATENCY', 60000) : env('CONSUL_LATENCY', 0) }
headers:
response:
X-Consul-Index: ${ parseInt((location.search.index || 1)) + 1}

View File

@ -0,0 +1,70 @@
[
${
range(
env(
'CONSUL_SERVICE_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_SERVICE_MAX', 10)
) + parseInt(env('CONSUL_SERVICE_MIN', 1))
)
)
).map((item, i) => `
{
"Name": "service-${i}",
${i === 1 ? `
"Namespace": "default",
` : `
"Namespace": "${fake.hacker.noun()}-ns-${i}",
`}
"Tags": [
${
range(env('CONSUL_TAG_COUNT', fake.random.number(10))).map(
function(item, i)
{
return `"${fake.hacker.noun()}"`;
}
)
}
],
"Nodes": [
${
range(env('CONSUL_NODE_COUNT', 100)).map(
function(item, i)
{
return `"node-${i}"`;
}
)
}
],
"InstanceCount": ${fake.helpers.randomize([fake.random.number({min: 1, max: 100})])},
"ChecksPassing":${fake.random.number({min: 1, max: env('CONSUL_CHECK_COUNT', fake.random.number(10))})},
"ChecksWarning":${fake.random.number({min: 0, max: env('CONSUL_CHECK_COUNT', fake.random.number(10))})},
"ChecksCritical":${fake.random.number({min: 0, max: env('CONSUL_CHECK_COUNT', fake.random.number(10))})},
${ fake.random.number({min: 1, max: 10}) > 2 ? `
"ExternalSources": [
${
range(fake.random.number({min: 1, max: 1})).map(
function(item, i)
{
return `"${fake.helpers.randomize(['consul', 'nomad', 'terraform', 'kubernetes', 'aws', ''])}"`;
}
)
}
],
` : `` }
"GatewayConfig": {
"Addresses": [
${
range(fake.random.number(6)).map(
function(item, i)
{
return `"${fake.random.number({min: 1, max: 10}) > 8 ? `*.`: ``}${fake.internet.domainName()}:${fake.random.number({min: 0, max: 65535})}"`;
}
)
}
]
}
}
`)}
]

View File

@ -0,0 +1,5 @@
---
"*":
GET:
"*":
latency: ${env('CONSUL_LATENCY', 0)}

View File

@ -0,0 +1,181 @@
{
"status": "success",
"data": {
"resultType": "vector",
"result": [
${
[1].map(function(_){
var type = "service";
var proto = "tcp";
var q = location.search.query;
// Match the relabel arguments since "downstream" appears in both
// "service" and "upstream" type queries' metric names while
// "upstream" appears in downstream query metric names (confusingly).
if (q.match('"upstream"')) {
type = "upstream";
} else if (q.match('"downstream"')) {
type = "downstream";
}
if (q.match('envoy_http_')) {
proto = "http";
}
// NOTE!!! The logic below to pick the upstream/downstream service
// names must exactly match the logic in internal/ui/service-topology/_
// If you change this, change it there too!
// Pick a number of down/upstreams to return based on the cookie variable.
// If you change anything about this variable or it's default, you'll need
// to change the topology endpoint to match.
var numResults = 1;
if (type === "upstream") {
numResults = env("CONSUL_UPSTREAM_COUNT", 3);
}
if (type === "downstream") {
numResults = env("CONSUL_DOWNSTREAM_COUNT", 5);
}
var genFakeServiceNames = function(num) {
// Seed faker by the number of results we want to make it deterministic
// here and in other correlated endpoints.
fake.seed(num);
var serviceNames = [];
for (var i = 0; i < num; i++) {
serviceNames.push(`service-${fake.random.number({min:0, max:99})}`)
}
return serviceNames
};
// Figure out the actual name for the target service
var targetService = "invalid-local-cluster";
var m = q.match(/local_cluster="([^"]*)"/);
if (m && m.length >= 2 && m[1] != "") {
targetService = m[1];
}
m = q.match(/consul_service="([^"]*)"/);
if (type == "downstream" && m && m.length >= 2 && m[1] != "") {
// downstreams don't have the same selector for the main service
// name.
targetService = m[1];
}
var serviceNames = [];
switch(type) {
case "downstream": // fallthrough
case "upstream":
serviceNames = genFakeServiceNames(numResults);
break;
default:
// fallthrough
case "service":
serviceNames = [targetService];
break;
}
// little helper to get a deterministic number from the target service
// name string. NOTE: this should be the same as in service-topology
// endpoint so metrics match what is requested.
var hashStr = function(s) {
for(var i = 0, h = 0xdeadbeef; i < s.length; i++)
h = Math.imul(h ^ s.charCodeAt(i), 2654435761);
return (h ^ h >>> 16) >>> 0;
};
var serviceProto = "tcp"
// Randomly pick the serviceProtocol which will affect which types of
// stats we return for downstream clusters. But we need it to be
// deterministic for a given service name so that all the downstream
// stats are consistently typed.
fake.seed(hashStr(targetService))
if (fake.random.number(1) > 0.5) {
serviceProto = "http";
}
// For up/downstreams only return HTTP metrics half of the time.
// For upstreams it's based on the upstream's protocol which might be
// mixed so alternate protocols for upstreams.
if (type == "upstream") {
// Pretend all odd service indexes are tcp and even are http
var wantMod = 0;
if (proto == "tcp") {
wantMod = 1;
}
serviceNames = serviceNames.filter(function(x, i){ return i%2 == wantMod })
}
// For downstreams it's based on the target's protocol which we
// don't really know but all downstreams should be the same type
// so only return metrics for that protocol.
if (type == "downstream" && proto == "http" && serviceProto != "http") {
serviceNames = [];
}
// Work out which metric is being queried to make them more realistic.
var range = 100;
switch(proto) {
case "http":
if (q.match('envoy_response_code_class="5"')) {
// It's error rate make it a percentage
range = 30;
} else if (q.match("rq_completed")) {
// Requests per second
range = 1000;
} else if (q.match("quantile\\(0.99")) {
// 99 percentile time in ms make it longer than 50 percentile
range = 5000;
} else if (q.match("quantile\\(0.5")) {
// 50th percentile
range = 500;
}
break;
case "tcp":
if (q.match('cx_total')) {
// New conns per second
range = 100;
} else if (q.match('cx_rx_bytes')) {
// inbound data rate tends to be lower than outbound
range = 0.5 * 1e9;
} else if (q.match('cx_tx_bytes')) {
// inbound data rate
range = 1e9;
}
// no route/connect faile are OK with default 0-100
break;
}
var randExp = function(max, lambda) {
return (-Math.log(1-(1-Math.exp(-lambda))*Math.random())/lambda) * max;
}
// Now generate the data points
return serviceNames.map(function(name, i){
var metric = `{}`;
switch(type) {
default:
break;
case "upstream":
// TODO: this should really return tcp proxy label for tcp
// metrics but we don't look at that for now.
metric = `{"upstream": "${name}", "envoy_http_conn_manager_prefix": "${name}"}`;
break;
case "downstream":
metric = `{"downstream": "${name}", "local_cluster": "${name}"}`;
break;
}
return `{
"metric": ${metric},
"value": [
${Date.now()/1000},
"${randExp(range, 20)}"
]
}`;
}).join(",")
})[0]
}
]
}
}

View File

@ -0,0 +1,90 @@
{
"status": "success",
"data": {
"resultType": "matrix",
"result": [
${
// We need 15 minutes worth of data at 10 second resoution. Currently we
// always query for two series together so loop twice over this.
[0, 1].map(function(i){
var timePeriodMins = 15;
var resolutionSecs = 10;
var numPoints = (timePeriodMins*60)/resolutionSecs;
var time = (Date.now()/1000) - (timePeriodMins*60);
var q = location.search.query;
var proto = "tcp";
var range = 1000;
var riseBias = 10;
var fallBias = 10;
var volatility = 0.2;
var label = "";
if (q.match('envoy_listener_http_downstream_rq_xx')) {
proto = "http"
// Switch random value ranges for total vs error rates
switch(i) {
case 0:
range = 1000; // up to 1000 rps for success
label = "Successes";
break;
case 1:
range = 500; // up to 500 errors per second
fallBias = 1; // fall quicker than we rise
riseBias = 30; // start low generally
volatility = 1;
label = "Errors";
break;
}
} else {
// Type tcp
switch(i) {
case 0:
range = 0.5 * 1e9; // up to 500 mbps recieved
label = "Inbound";
break;
case 1:
range = 1e9; // up to 1 gbps
label = "Outbound"
break;
}
}
var randExp = function(max, lambda) {
return (-Math.log(1-(1-Math.exp(-lambda))*Math.random())/lambda) * max;
}
// Starting value
var value = randExp(range, riseBias);
if (value > range) {
value = range;
}
var points = [];
for (var i = 0; i < numPoints; i++) {
points.push(`[${time}, "${value}"]`);
time = time + resolutionSecs;
var rising = (Math.random() > 0.5);
delta = volatility * randExp(range, rising ? riseBias : fallBias);
if (!rising) {
// Make it a negative change
delta = 0-delta;
}
value = value + delta
if (value > range) {
value = range;
}
if (value < 0) {
value = 0;
}
}
return `
{
"metric": {"label": "${label}"},
"values": [${points.join(",")}]
}`;
})
}
]
}
}

View File

@ -0,0 +1,8 @@
---
"*":
GET:
"*":
latency: ${ location.search.index ? env('CONSUL_LATENCY', 60000) : env('CONSUL_LATENCY', 0) }
headers:
response:
X-Consul-Index: ${ parseInt((location.search.index || 1)) + 1}

View File

@ -0,0 +1,105 @@
${[1].map(() => {
const services = range(
env(
'CONSUL_SERVICE_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_SERVICE_MAX', 10)
) + parseInt(env('CONSUL_SERVICE_MIN', 1))
)
)
).map(
(item, i) => {
const service = `service-${i}`;
return {
"ID": i === 0 ? 'service-0-with-id' : fake.helpers.randomize([service, service + '-ID']),
"Service": service,
};
}
);
return `
{
"ID":"${node = location.pathname.get(4)}",
"Node":"${node}",
"Address":"${ip = fake.internet.ip()}",
"TaggedAddresses":{"lan":"${ip}","wan":"${ip}"},
"Meta":{
"consul-network-segment":"",
"consul-dashboard-url": "${fake.internet.protocol()}://${fake.internet.domainName()}/?id={{Node}}"
},
"Services":[
${
services.map(
function(item, i)
{
const service = `service-${i}`;
return `
{
"ID": "${item.ID}",
"Service":"${item.Service}",
"Tags":[
${
range(
env(
'CONSUL_TAG_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_TAG_MAX', 10)
) + parseInt(env('CONSUL_TAG_MIN', 1))
)
)
).map(
function(item, i)
{
return `"${fake.hacker.noun()}"`;
}
)
}
],
${ fake.random.number({min: 1, max: 10}) > 2 ? `
"Meta": {
"external-source": "${fake.helpers.randomize(['consul', 'nomad', 'terraform', 'kubernetes', ''])}"
},
` : `` }
"Address":"",
"Port": ${ i === 0 ? '65535' : fake.random.number({min: 0, max: 65534})},
"EnableTagOverride":false,
"CreateIndex":11,
"ModifyIndex":11
}
`;
}
)
}
],
"Checks":[
${
range(env('CONSUL_CHECK_COUNT', 10)).map(
function(item, i)
{
const service = fake.random.number({min: 0, max: 10}) > 5 ? fake.helpers.randomize(services) : {ID: '', Service: ''};
return `
{
"Node":"${location.pathname.get(4)}",
"CheckID":"${fake.hacker.noun()}Health",
"Name":"${fake.hacker.noun()} Status",
"Type": "${fake.helpers.randomize(['script', 'http', 'tcp', 'ttl', 'docker', 'grpc', 'alias'])}",
"Status":"${fake.helpers.randomize(['passing', 'warning', 'critical'])}",
"Notes":"${fake.lorem.paragraph()}",
"Output":"${fake.internet.ipv6()} ${fake.internet.protocol()}://${fake.internet.userName()}:${fake.internet.password()}@${fake.internet.domainName()} ${fake.internet.userAgent()}",
"ServiceID":"${service.ID}",
"ServiceName":"${service.Service}",
"ServiceTags":null,
"Definition":{},
"CreateIndex":12,
"ModifyIndex":230113
}
`;
}
)
}
]
}`
})}

View File

@ -0,0 +1,90 @@
[
${
range(
env(
'CONSUL_NODE_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_NODE_MAX', 10)
) + parseInt(env('CONSUL_NODE_MIN', 1))
)
)
).map(
function(item, i)
{
return `
{
"ID":"${fake.random.uuid()}",
"Node":"node-${i}",
"Address":"${fake.internet.ip()}",
"TaggedAddresses":{
"lan":"${fake.internet.ip()}",
"wan":"${fake.internet.ip()}"
},
"Meta": {
"consul-network-segment":""
},
"Services":[
${
range(fake.random.number(4) + 1).map(
function(item, i) {
const service = `service-${i}`;
return `
{
"ID":"${service}",
"Service":"${service}",
"Tags":[
${
range(env('CONSUL_TAG_COUNT', fake.random.number(10))).map(
function(item, i)
{
return `"${fake.hacker.noun()}"`;
}
)
}
],
"Address":"",
"Port":${fake.random.number({min: 0, max: 65535})},
"EnableTagOverride":false,
"CreateIndex":5,
"ModifyIndex":5
}
`;
}
)
}
],
"Checks":[
${
range(env('CONSUL_CHECK_COUNT', fake.random.number(9) + 1)).map(
function(item, j)
{
const passing = i > 7 || j > fake.random.number(4);
return `
{
"Node":"node-${i}",
"CheckID":"${fake.hacker.noun()}Health",
"Name":"${fake.hacker.noun()} Status",
"Type": "${fake.helpers.randomize(['script', 'http', 'tcp', 'ttl', 'docker', 'grpc', 'alias'])}",
"Status":"${ passing ? "passing" : fake.helpers.randomize(['warning', 'critical'])}",
"Notes":"${fake.lorem.paragraph()}",
"Output":"${fake.internet.ipv6()} ${fake.internet.protocol()}://${fake.internet.userName()}:${fake.internet.password()}@${fake.internet.domainName()} ${fake.internet.userAgent()}",
"ServiceID":"",
"ServiceName":"",
"ServiceTags":["Tag"],
"Definition":{},
"CreateIndex":5,
"ModifyIndex":5
}
`;
}
)
}
]
}
`;
}
)
}
]

View File

@ -0,0 +1,23 @@
[
${
range(
env(
'CONSUL_OIDC_PROVIDER_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_OIDC_PROVIDER_MAX', 10)
) + parseInt(env('CONSUL_OIDC_PROVIDER_MIN', 1))
)
)
).map((item, i) => {
const name = `${fake.company.companyName()}`;
return `
{
"Name": "${name.split(' ').join('-').toLowerCase()}",
"DisplayName": "${name}",
"Kind": "${fake.helpers.randomize(['no-icon', 'google', 'okta', 'auth0', 'microsoft'])}",
"Namespace": "default"
}
`})
}
]

View File

@ -0,0 +1,9 @@
---
"*":
GET:
"*":
latency: ${ location.search.index ? env('CONSUL_LATENCY', 60000) : env('CONSUL_LATENCY', 0) }
headers:
response:
X-Consul-Index: ${ parseInt((location.search.index || 1)) + 1}

View File

@ -0,0 +1,113 @@
${
[1].map(() => {
const dc = location.search.dc;
// NOTE!!! The logic below to pick the upstream/downstream service
// names must exactly match the logic in internal/ui/metrics-proxy/.../query
// If you change this, change it there too!
// Pick a number of down/upstreams to return based on the cookie variable.
// If you change anything about this variable or it's default, you'll need
// to change the topology endpoint to match.
var numUp = env("CONSUL_UPSTREAM_COUNT", 3);
var numDown = env("CONSUL_DOWNSTREAM_COUNT", 5);
var genFakeServiceNames = function(num) {
// Seed faker by the number of results we want to make it deterministic
// here and in other correlated endpoints.
fake.seed(num);
var serviceNames = [];
for (var i = 0; i < num; i++) {
serviceNames.push(`service-${fake.random.number({min:0, max:99})}`)
}
return serviceNames
};
var upstreams = genFakeServiceNames(numUp);
var downstreams = genFakeServiceNames(numDown);
const targetService = location.pathname.toString().replace('/v1/internal/ui/service-topology/', '')
// little helper to get a deterministic number from the target service
// name string. NOTE: this should be the same as in metrics-proxy/.../query
// endpoint so metrics match what is requested.
var hashStr = function(s) {
for(var i = 0, h = 0xdeadbeef; i < s.length; i++)
h = Math.imul(h ^ s.charCodeAt(i), 2654435761);
return (h ^ h >>> 16) >>> 0;
};
var serviceProto = "tcp"
// Randomly pick the serviceProtocol which will affect which types of
// stats we return for downstream clusters. But we need it to be
// deterministic for a given service name so that all the downstream
// stats are consistently typed.
fake.seed(hashStr(targetService))
if (fake.random.number(1) > 0.5) {
serviceProto = "http";
}
return `
{
"Protocol": "${serviceProto}",
"FilteredByACLs": ${fake.random.boolean()},
"Upstreams":
[
${
upstreams.map((item, i) => {
let hasPerms = fake.random.boolean();
// if hasPerms is true allowed is always false as some restrictions apply
let allowed = hasPerms ? false : fake.random.boolean();
return `
{
"Name": "${item}",
"Datacenter": "${dc}",
${i === 1 ? `
"Namespace": "default",
` : `
"Namespace": "${fake.hacker.noun()}-ns-${i}",
`}
"ChecksPassing":${fake.random.number({min: 1, max: env('CONSUL_CHECK_COUNT', fake.random.number(10))})},
"ChecksWarning":${fake.random.number({min: 0, max: env('CONSUL_CHECK_COUNT', fake.random.number(10))})},
"ChecksCritical":${fake.random.number({min: 0, max: env('CONSUL_CHECK_COUNT', fake.random.number(10))})},
"Intention": {
"Allowed": ${allowed},
"HasPermissions": ${hasPerms},
"ExternalSource": "${fake.helpers.randomize(['nomad', 'kubernetes', ''])}",
"HasExact": ${fake.random.boolean()}
}
}
`})}
],
"Downstreams":
[
${
downstreams.map((item, i) => {
let hasPerms = fake.random.boolean();
// if hasPerms is true allowed is always false as some restrictions apply
let allowed = hasPerms ? false : fake.random.boolean();
return `
{
"Name": "${item}",
"Datacenter": "${dc}",
${i === 1 ? `
"Namespace": "default",
` : `
"Namespace": "${fake.hacker.noun()}-ns-${i}",
`}
"ChecksPassing":${fake.random.number({min: 1, max: env('CONSUL_CHECK_COUNT', fake.random.number(10))})},
"ChecksWarning":${fake.random.number({min: 0, max: env('CONSUL_CHECK_COUNT', fake.random.number(10))})},
"ChecksCritical":${fake.random.number({min: 0, max: env('CONSUL_CHECK_COUNT', fake.random.number(10))})},
"Intention": {
"Allowed": ${allowed},
"HasPermissions": ${hasPerms},
"ExternalSource": "${fake.helpers.randomize(['nomad', 'kubernetes', ''])}",
"HasExact": ${fake.random.boolean()}
}
}
`})}
]
}`
})
}

View File

@ -0,0 +1,109 @@
${[0].map(
() => {
let prevKind;
let name;
const gateways = ['mesh-gateway', 'ingress-gateway', 'terminating-gateway'];
return `
[
${
range(
env(
'CONSUL_SERVICE_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_SERVICE_MAX', 10)
) + parseInt(env('CONSUL_SERVICE_MIN', 1))
)
)
).map(
function(item, i)
{
let kind;
switch(i) {
case 0:
kind = '';
break;
case 1:
kind = 'connect-proxy';
break;
case 2:
case 3:
case 4:
kind = gateways[i - 2];
break;
default:
kind = prevKind === '' ? fake.helpers.randomize(['connect-proxy', '']) : fake.helpers.randomize(['', '', '', ''].concat(gateways));
}
prevKind = kind;
if(kind === 'connect-proxy') {
name = `${name}-proxy`;
} else {
name = `service-${i}${ kind !== '' ? `-${kind.replace('connect-', '')}` : '' }`;
}
return `
{
"Name":"${name}",
${typeof location.search.ns !== 'undefined' ? `
"Namespace": "${location.search.ns}",
` : ``}
"Tags": [
${
range(
env(
'CONSUL_TAG_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_TAG_MAX', 10)
) + parseInt(env('CONSUL_TAG_MIN', 1))
)
)
).map(
function(item, i)
{
return `"${fake.hacker.noun()}"`;
}
)
}
],
"ConnectedWithProxy":${fake.random.boolean()},
"ConnectedWithGateway":${fake.random.boolean()},
"GatewayConfig": {
"AssociatedServiceCount": ${fake.random.number({min: 1, max: 4000})}
},
${kind !== '' ? `
"Kind": "${kind}",
` : `` }
"InstanceCount": ${fake.helpers.randomize([fake.random.number({min: 1, max: 4000}), fake.random.number({min: 1, max: 90}), fake.random.number({min: 1, max: 10})])},
${ fake.random.number({min: 1, max: 10}) > 2 ? `
"ExternalSources": [
${
range(fake.random.number({min: 1, max: 1})).map(
function(item, i)
{
return `"${fake.helpers.randomize(['consul', 'nomad', 'terraform', 'kubernetes', 'aws', ''])}"`;
}
)
}
],
` : `` }
"Nodes":[
${
range(env('CONSUL_NODE_COUNT', 100)).map(
function(item, i)
{
return `"node-${i}"`;
}
)
}
],
"ChecksPassing":${fake.random.number({min: 1, max: env('CONSUL_CHECK_COUNT', fake.random.number(10))})},
"ChecksWarning":${fake.random.number({min: 0, max: env('CONSUL_CHECK_COUNT', fake.random.number(10))})},
"ChecksCritical":${fake.random.number({min: 0, max: env('CONSUL_CHECK_COUNT', fake.random.number(10))})}
}
`;
}
)
}
]
`})}

View File

@ -0,0 +1,12 @@
---
"*":
PUT:
"_":
"*":
latency: ${ env('CONSUL_LATENCY', 0)}
GET:
"*":
latency: ${ location.search.index ? env('CONSUL_LATENCY', 60000) : env('CONSUL_LATENCY', 0) }
headers:
response:
X-Consul-Index: ${ parseInt((location.search.index || 1)) + 1}

View File

@ -0,0 +1,50 @@
${
http.method == "GET" ?
typeof location.search.keys !== 'undefined' ? `
[
${
range(
env(
'CONSUL_KV_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_KV_MAX', 10)
) + parseInt(env('CONSUL_KV_MIN', 1))
)
)
).map(
function(item, i) {
return `"${
range(
fake.random.number(
{max: env('CONSUL_KV_MAX_DEPTH', 0)}
)
).reduce(
function(prev, item, i, arr) {
return `${prev}/${fake.lorem.word()}-${i}`
},
`${i}-${i === 0 ? 'key-value' : fake.lorem.word()}`
)}"`;
}
)
}
]
` : `
[
{
"LockIndex":0,
"Key":"${
location.pathname.slice(3)
}",
${typeof location.search.ns !== 'undefined' ? `
"Namespace": "${location.search.ns}",
` : ``}
"Flags":0,
"Value":"VHVlIEZlYiAgNiAxMzoxOToyMiBVVEMgMjAxOA==",
"CreateIndex":467034,
"ModifyIndex":467499,
"Session": "${fake.random.uuid()}"
}
]
` : "true"
}

View File

@ -0,0 +1,28 @@
[
${
range(
env(
'CONSUL_KV_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_KV_MAX', 10)
) + parseInt(env('CONSUL_KV_MIN', 1))
)
)
).map(
function(item, i) {
return `"${
range(
fake.random.number(
{max: env('CONSUL_KV_MAX_DEPTH', 0)}
)
).reduce(
function(prev, item, i, arr) {
return `${prev}/${fake.lorem.word()}-${i}`
},
`${i}-${i === 0 ? 'key-value' : fake.lorem.word()}`
)}"`;
}
)
}
]

View File

@ -0,0 +1,24 @@
{
"Name": "${location.pathname.get(2)}",
"Description": "${fake.lorem.sentence()}",
"ACLs": {
"PolicyDefaults": [
${range(env('CONSUL_POLICY_COUNT', 3)).map((i) => `
{
"ID": "${fake.random.uuid()}-${i}",
"Name": "${fake.hacker.noun()}-policy"
}
`)}
],
"RoleDefaults": [
${range(env('CONSUL_ROLE_COUNT', 3)).map((i) => `
{
"ID": "${fake.random.uuid()}-${i}",
"Name": "${fake.hacker.noun()}-role"
}
`)}
]
},
"CreateIndex": 12,
"ModifyIndex": 16
}

View File

@ -0,0 +1,64 @@
[
{
"Name": "default",
"Description": "The default namespace",
"ACLs": {
"PolicyDefaults": [
${range(env('CONSUL_POLICY_COUNT', 3)).map((i) => `
{
"ID": "${fake.random.uuid()}-${i}",
"Name": "${fake.hacker.noun()}-policy"
}
`)}
],
"RoleDefaults": [
${range(env('CONSUL_ROLE_COUNT', 3)).map((i) => `
{
"ID": "${fake.random.uuid()}-${i}",
"Name": "${fake.hacker.noun()}-role"
}
`)}
]
}
}
${range(
env(
'CONSUL_NSPACE_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_NSPACE_MAX', 10)
) + parseInt(env('CONSUL_NSPACE_MIN', 1))
)
) - 1
).map(i => `
${i === 0 ? `
,
` : ``}
{
"Name": "${fake.hacker.noun()}-ns-${i}",
"ACLs": {
"PolicyDefaults": [
${range(env('CONSUL_POLICY_COUNT', 3)).map((i) => `
{
"ID": "${fake.random.uuid()}-${i}",
"Name": "${fake.hacker.noun()}-policy"
}
`)}
],
"RoleDefaults": [
${range(env('CONSUL_ROLE_COUNT', 3)).map((i) => `
{
"ID": "${fake.random.uuid()}-${i}",
"Name": "${fake.hacker.noun()}-role"
}
`)}
]
},
${fake.random.boolean() ? `
"Description": "${fake.lorem.sentence()}",
` : ``}
"CreateIndex": 12,
"ModifyIndex": 16
}
`)}
]

View File

@ -0,0 +1 @@
true

View File

@ -0,0 +1,17 @@
[
{
"ID":"${location.pathname.get(3)}",
"Name":"${fake.hacker.noun()}",
"Namespace": "${
typeof location.search.ns !== 'undefined' ? location.search.ns :
typeof http.body.Namespace !== 'undefined' ? http.body.Namespace : 'default'
}",
"Node":"node-1",
"Checks":["serfHealth"],
"LockDelay":15000000000,
"Behavior":"${fake.helpers.randomize(['release', 'delete'])}",
"TTL":"",
"CreateIndex":2782,
"ModifyIndex":2782
}
]

View File

@ -0,0 +1,8 @@
---
"*":
GET:
"*":
latency: ${ location.search.index ? env('CONSUL_LATENCY', 60000) : env('CONSUL_LATENCY', 0) }
headers:
response:
X-Consul-Index: ${ parseInt((location.search.index || 1)) + 1}

View File

@ -0,0 +1,32 @@
[
${
range(
env(
'CONSUL_SESSION_COUNT',
Math.floor(
(
Math.random() * env('CONSUL_SESSION_MAX', 5)
) + parseInt(env('CONSUL_SESSION_MIN', 1))
)
)
).map(
function(item, i) {
// TTL = "" | 10:84600
return `{
"ID":"${fake.random.uuid()}",
"Name":"${fake.hacker.noun()}",
${typeof location.search.ns !== 'undefined' ? `
"Namespace": "${location.search.ns}",
` : ``}
"Node":"${location.pathname.get(3)}",
"Checks":["serfHealth"],
"LockDelay":15000000000,
"Behavior":"${fake.helpers.randomize(['release', 'delete'])}",
"TTL":"",
"CreateIndex":2782,
"ModifyIndex":2782
}`;
}
)
}
]

View File

@ -0,0 +1 @@
"211.245.86.75:8500"

View File

@ -58,7 +58,6 @@
"@ember/render-modifiers": "^1.0.2",
"@glimmer/component": "^1.0.0",
"@glimmer/tracking": "^1.0.0",
"@hashicorp/consul-api-double": "^6.1.4",
"@hashicorp/ember-cli-api-double": "^3.1.0",
"@storybook/addon-actions": "^6.0.27",
"@storybook/addon-essentials": "^6.0.27",