Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Kong 0.10 #2

Merged
merged 3 commits into from Apr 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Empty file modified bin/cli.js 100644 → 100755
Empty file.
15 changes: 11 additions & 4 deletions lib/validation/api.js
Expand Up @@ -13,10 +13,17 @@ var joi = require('joi')

module.exports = joi.object({
name: joi.string()
, request_path: joi.string().optional()
, request_host: joi.string().when('request_path',{is:joi.empty(), then:joi.optional(), otherwise:joi.optional() })
, strip_request_path: joi.boolean().default( false )
, preserve_host: joi.boolean().default( false ).description('Preserves the original Host header sent by the client, instead of replacing it with the hostname of the upstream_url')
, hosts: joi.array().unique()
, uris: joi.array().items(joi.string().optional())
, methods: joi.array().unique()
, upstream_url: joi.string().required().description("The base target URL that points to your API server, this URL will be used for proxying requests. For example, https://mockbin.com")
, strip_uri: joi.boolean()
, preserve_host: joi.boolean().description('Preserves the original Host header sent by the client, instead of replacing it with the hostname of the upstream_url')
, retries: joi.number()
, upstream_connect_timeout: joi.number()
, upstream_read_timeout: joi.number()
, upstream_send_timeout: joi.number()
, https_only: joi.boolean()
, http_if_terminated: joi.boolean()
, plugins: joi.object().unknown().optional()
});
2 changes: 1 addition & 1 deletion script/test.js
Expand Up @@ -31,7 +31,7 @@ var child_process = require('child_process') // child proces for s
;

root = path.resolve(__dirname)
root = path.join(root, "../**/test/*.spec.js" )
root = path.join(root, `../**/test/*.spec.js` )
// inject some test vars into the env
env.MOCHA_COLORS = 1

Expand Down
43 changes: 21 additions & 22 deletions test/king.spec.js
Expand Up @@ -75,9 +75,14 @@ describe('King', function(){
apis:[{
name:'__test',
upstream_url:'http://localhost:9000',
request_path:'/test',
strip_request_path:true,
request_path:'/test'
uris:['/test'],
strip_uri:true,
retries: 7,
upstream_connect_timeout: 90000,
upstream_read_timeout: 90000,
upstream_send_timeout: 90000,
http_if_terminated: false,
https_only: false
}]
,onSync: function(){
done();
Expand Down Expand Up @@ -106,9 +111,8 @@ describe('King', function(){
apis:[{
name:'__test',
upstream_url:'http://localhost:9000',
request_path:'/test',
strip_request_path:true,
request_path:'/test',
uris:['/test'],
strip_uri:true,
plugins:{
'http-log':{
config:{
Expand All @@ -134,9 +138,8 @@ describe('King', function(){
apis:[{
name:'__test',
upstream_url:'localhost:9000',
request_path:'/test',
strip_request_path:true,
request_path:'/test'
uris:['/test'],
strip_uri:true
}]
});
k.sync()
Expand All @@ -158,9 +161,8 @@ describe('King', function(){
apis:[{
name:'__test',
upstream_url:'http://localhost:9000',
request_path:'/test',
strip_request_path:true,
request_path:'/test',
uris:['/test'],
strip_uri:true,
plugins:{
'bad-plugin':{
config:{
Expand Down Expand Up @@ -190,9 +192,8 @@ describe('King', function(){
apis:[{
name:'__test',
upstream_url:'http://localhost:9000',
request_path:'/test',
strip_request_path:true,
request_path:'/test',
uris:['/test'],
strip_uri:true,
plugins:{
'http-log':{
configs:{
Expand Down Expand Up @@ -222,9 +223,8 @@ describe('King', function(){
apis:[{
name:'__test',
upstream_url:'http://localhost:9000',
request_path:'/test',
strip_request_path:true,
request_path:'/test',
uris:['/test'],
strip_uri:true,
plugins:{
'http-log':{
config:{
Expand Down Expand Up @@ -255,15 +255,14 @@ describe('King', function(){
apis:[{
name:'__test',
upstream_url:'http://localhost:9000',
request_path:'/test',
strip_request_path:false,
request_path:'/test'
uris:['/test'],
strip_uri:false
}]
,onSync:function(){
setTimeout(function(){
k2.request('get','apis','__test')
.then( function( data ){
assert.strictEqual(data.body.strip_request_path, false);
assert.strictEqual(data.body.strip_uri, false);
done();
})
.catch( done )
Expand Down