-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
213 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,44 @@ | ||
const test = require('ava'); | ||
const fse = require('fs-extra'); | ||
const rp = require('request-promise'); | ||
const shell = require('shelljs'); | ||
const initData = require('./init-data/'); | ||
const db = require('./kong-mock-server/lib/db'); | ||
|
||
test.before(t => { | ||
shell.exec('node ./kong-mock-server/index', (code, stdout, stderr) => { | ||
console.log('Mock Server Exit code:', code); | ||
console.log('Mock Server output:', stdout); | ||
console.log('Mock Server stderr:', stderr); | ||
}); | ||
shell.exec('sleep 2'); | ||
fse.writeJsonSync( | ||
'./kcm-config.json', | ||
{ | ||
main: 'localhost:3001', | ||
sec_test: 'localhost:3001' | ||
}, | ||
{ | ||
spaces: 2 | ||
} | ||
); | ||
}); | ||
|
||
test.beforeEach(async t => { | ||
const numRemoved = await db.removeAsync({}, { multi: true }); | ||
console.log(`nedb was flushed! (${numRemoved} items)`); | ||
await Promise.all( | ||
Object.keys(initData).map(async obj => { | ||
await db.insertAsync(initData.obj); | ||
}) | ||
); | ||
}); | ||
|
||
test('DEBUG=kcm* kcm dump --all', t => { | ||
const ret = shell.exec('DEBUG=kcm* kcm dump --all'); | ||
|
||
t.is(ret.code, 0); | ||
const api1 = require('./main/apis/60d8c00b-1d2e-4dab-8dfc-b3a8e04aa891.json'); | ||
t.is(api1.name, 'api1'); | ||
t.is(api1.upstream_url, 'mockbin.com'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
[ | ||
{ | ||
"name": "api1", | ||
"hosts": ["1.com", "2.com"], | ||
"upstream_url": "mockbin.com", | ||
"http_if_terminated": true, | ||
"upstream_read_timeout": 6000, | ||
"preserve_host": false, | ||
"upstream_connect_timeout": 6000, | ||
"strip_uri": true, | ||
"https_only": false, | ||
"retries": 5, | ||
"upstream_send_timeout": 6000, | ||
"created_at": 1502013470934, | ||
"id": "60d8c00b-1d2e-4dab-8dfc-b3a8e04aa891" | ||
}, | ||
{ | ||
"name": "api2", | ||
"hosts": ["1.com", "2.com", "3.com"], | ||
"upstream_url": "mockbin.com", | ||
"http_if_terminated": true, | ||
"upstream_read_timeout": 6000, | ||
"preserve_host": false, | ||
"upstream_connect_timeout": 6000, | ||
"strip_uri": true, | ||
"https_only": false, | ||
"retries": 5, | ||
"upstream_send_timeout": 6000, | ||
"created_at": 1502013504702, | ||
"id": "fc111281-5a6f-41fd-abf8-d4424250e25d" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[ | ||
{ | ||
"id": "21b69eab-09d9-40f9-a55e-c4ee47fada68", | ||
"cert": "-----BEGIN CERTIFICATE-----...", | ||
"key": "-----BEGIN RSA PRIVATE KEY-----...", | ||
"snis": ["mockbin.com"], | ||
"created_at": 1485521710265 | ||
}, | ||
{ | ||
"id": "95b19eab-09d9-40f9-a55e-c4ee47fada68", | ||
"cert": "-----BEGIN CERTIFICATE-----...", | ||
"key": "-----BEGIN RSA PRIVATE KEY-----...", | ||
"snis": ["example.com"], | ||
"created_at": 1485521710266 | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[ | ||
{ | ||
"id": "4d924084-1adb-40a5-c042-63b19db421d1", | ||
"custom_id": "abc123", | ||
"created_at": 1422386534 | ||
}, | ||
{ | ||
"id": "2d324024-8fdb-20a5-g044-62b19db411d1", | ||
"custom_id": "test", | ||
"created_at": 1422386535 | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const fs = require('fs'); | ||
|
||
const ret = {}; | ||
|
||
fs | ||
.readdirSync(__dirname) | ||
.filter(file => file.indexOf('.') !== 0 && file !== 'index.js') | ||
.forEach(file => { | ||
const item = file.split('.')[0]; | ||
ret[item] = require(`./${item}`); | ||
ret[item] = ret[item].map(o => { | ||
o.type = item; | ||
return o; | ||
}); | ||
}); | ||
|
||
module.exports = ret; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[ | ||
{ | ||
"id": "4d924084-1adb-40a5-c042-63b19db421d1", | ||
"api_id": "5fd1z584-1adb-40a5-c042-63b19db49x21", | ||
"name": "rate-limiting", | ||
"config": { | ||
"minute": 20, | ||
"hour": 500 | ||
}, | ||
"enabled": true, | ||
"created_at": 1422386534 | ||
}, | ||
{ | ||
"id": "3d324d84-1sdb-30a5-c043-63b19db421d1", | ||
"consumer_id": "a3dX2dh2-1adb-40a5-c042-63b19dbx83hF4", | ||
"name": "halo-auth", | ||
"config": {}, | ||
"enabled": true, | ||
"created_at": 1422386534 | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[ | ||
{ | ||
"name": "mockbin.com", | ||
"ssl_certificate_id": "21b69eab-09d9-40f9-a55e-c4ee47fada68", | ||
"created_at": 1485521710265 | ||
}, | ||
{ | ||
"name": "example.com", | ||
"ssl_certificate_id": "34c49eab-09d9-40f9-a55e-c4ee47fada68", | ||
"created_at": 1485521710267 | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[ | ||
{ | ||
"id": "4661f55e-95c2-4011-8fd6-c5c56df1c9db", | ||
"target": "1.2.3.4:80", | ||
"weight": 15, | ||
"upstream_id": "13611da7-703f-44f8-b790-fc1e7bf51b3e", | ||
"created_at": 1485523507446 | ||
}, | ||
{ | ||
"id": "5552f66e-95c2-4011-8fd6-c5c56df1c9db", | ||
"target": "1.2.3.4:80", | ||
"weight": 15, | ||
"upstream_id": "13611da7-703f-44f8-b790-fc1e7bf51b3e", | ||
"created_at": 1485523507446 | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[ | ||
{ | ||
"id": "13611da7-703f-44f8-b790-fc1e7bf51b3e", | ||
"name": "service.v1.xyz", | ||
"orderlist": [1, 2, 7, 9, 6, 4, 5, 10, 3, 8], | ||
"slots": 10, | ||
"created_at": 1485521710265 | ||
}, | ||
{ | ||
"id": "24721da8-703f-44f8-b790-fc2e7bf51b3e", | ||
"name": "httpbin.com", | ||
"orderlist": [1, 11, 7, 9, 6, 4, 5, 10, 3, 8], | ||
"slots": 10, | ||
"created_at": 1485521710269 | ||
} | ||
] |
Submodule kong-mock-server
updated
11 files
+40 −1 | README.md | |
+138 −0 | controllers/apis.js | |
+59 −0 | controllers/certificates.js | |
+13 −0 | controllers/cluster.js | |
+55 −0 | controllers/consumers.js | |
+57 −0 | controllers/plugins.js | |
+56 −0 | controllers/snis.js | |
+107 −0 | controllers/upstreams.js | |
+20 −0 | index.js | |
+13 −0 | lib/db.js | |
+35 −0 | package.json |