Skip to content

Commit

Permalink
test: cleanup api definition strings
Browse files Browse the repository at this point in the history
Remove unnecessary fields, and compact others that are repetitive.
  • Loading branch information
mvdan authored and buger committed Sep 5, 2017
1 parent cbd22a5 commit 3f1e6c4
Show file tree
Hide file tree
Showing 17 changed files with 90 additions and 234 deletions.
15 changes: 3 additions & 12 deletions api_definition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@ import (

const sampleDefiniton = `{
"api_id": "1",
"org_id": "default",
"definition": {
"location": "header",
"key": "version"
},
"auth": {
"auth_header_name": "authorization"
},
"auth": {"auth_header_name": "authorization"},
"version_data": {
"versions": {
"v1": {
Expand All @@ -44,14 +41,11 @@ const sampleDefiniton = `{

const nonExpiringDef = `{
"api_id": "1",
"org_id": "default",
"definition": {
"location": "header",
"key": "version"
},
"auth": {
"auth_header_name": "authorization"
},
"auth": {"auth_header_name": "authorization"},
"version_data": {
"versions": {
"v1": {
Expand All @@ -73,14 +67,11 @@ const nonExpiringDef = `{

const nonExpiringMultiDef = `{
"api_id": "1",
"org_id": "default",
"definition": {
"location": "header",
"key": "version"
},
"auth": {
"auth_header_name": "authorization"
},
"auth": {"auth_header_name": "authorization"},
"version_data": {
"versions": {
"v1": {
Expand Down
20 changes: 5 additions & 15 deletions api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,14 @@ import (

const apiTestDef = `{
"api_id": "1",
"org_id": "default",
"definition": {
"location": "header",
"key": "version"
},
"auth": {
"auth_header_name": "authorization"
},
"auth": {"auth_header_name": "authorization"},
"version_data": {
"versions": {
"Default": {
"name": "Default"
}
"v1": {"name": "v1"}
}
},
"proxy": {
Expand Down Expand Up @@ -81,7 +76,7 @@ func createSampleSession() *SessionState {
"1": {
APIName: "Test",
APIID: "1",
Versions: []string{"Default"},
Versions: []string{"v1"},
},
},
}
Expand Down Expand Up @@ -642,20 +637,15 @@ func TestHotReloadMany(t *testing.T) {

const apiBenchDef = `{
"api_id": "REPLACE",
"org_id": "default",
"definition": {
"location": "header",
"key": "version"
},
"auth": {
"auth_header_name": "authorization"
},
"auth": {"auth_header_name": "authorization"},
"version_data": {
"not_versioned": true,
"versions": {
"Default": {
"name": "Default"
}
"v1": {"name": "v1"}
}
},
"proxy": {
Expand Down
8 changes: 2 additions & 6 deletions batch_requests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@ import (
const batchTestDef = `{
"api_id": "987999",
"org_id": "default",
"auth": {
"auth_header_name": "authorization"
},
"auth": {"auth_header_name": "authorization"},
"version_data": {
"not_versioned": true,
"versions": {
"Default": {
"name": "Default"
}
"v1": {"name": "v1"}
}
},
"proxy": {
Expand Down
72 changes: 24 additions & 48 deletions coprocess_id_extractor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,28 +159,20 @@ func computeSessionID(input []byte, baseMid *BaseMiddleware) (sessionID string)
const idExtractorCoProcessDef = `{
"api_id": "1",
"org_id": "default",
"auth": {
"auth_header_name": "authorization"
},
"auth": {"auth_header_name": "authorization"},
"version_data": {
"not_versioned": true,
"versions": {
"v1": {
"name": "v1"
}
"v1": {"name": "v1"}
}
},
"event_handlers": {
"events": {
"AuthFailure": [
{
"handler_name":"cp_dynamic_handler",
"handler_meta": {
"name": "my_handler"
}
}
]
}
"events": {"AuthFailure": [{
"handler_name":"cp_dynamic_handler",
"handler_meta": {
"name": "my_handler"
}
}]}
},
"custom_middleware": {
"pre": [{
Expand All @@ -204,28 +196,20 @@ const idExtractorCoProcessDef = `{
const valueExtractorFormSource = `{
"api_id": "1",
"org_id": "default",
"auth": {
"auth_header_name": "authorization"
},
"auth": {"auth_header_name": "authorization"},
"version_data": {
"not_versioned": true,
"versions": {
"v1": {
"name": "v1"
}
"v1": {"name": "v1"}
}
},
"event_handlers": {
"events": {
"AuthFailure": [
{
"handler_name":"cp_dynamic_handler",
"handler_meta": {
"name": "my_handler"
}
}
]
}
"events": {"AuthFailure": [{
"handler_name":"cp_dynamic_handler",
"handler_meta": {
"name": "my_handler"
}
}]}
},
"custom_middleware": {
"pre": [{
Expand All @@ -249,28 +233,20 @@ const valueExtractorFormSource = `{
const regexExtractorDef = `{
"api_id": "1",
"org_id": "default",
"auth": {
"auth_header_name": "authorization"
},
"auth": {"auth_header_name": "authorization"},
"version_data": {
"not_versioned": true,
"versions": {
"v1": {
"name": "v1"
}
"v1": {"name": "v1"}
}
},
"event_handlers": {
"events": {
"AuthFailure": [
{
"handler_name":"cp_dynamic_handler",
"handler_meta": {
"name": "my_handler"
}
}
]
}
"events": {"AuthFailure": [{
"handler_name":"cp_dynamic_handler",
"handler_meta": {
"name": "my_handler"
}
}]}
},
"custom_middleware": {
"id_extractor": {
Expand Down
56 changes: 17 additions & 39 deletions coprocess_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,36 +266,23 @@ func TestCoProcessReturnOverridesErrorMessage(t *testing.T) {

const basicCoProcessDef = `{
"api_id": "1",
"org_id": "default",
"auth": {
"auth_header_name": "authorization"
},
"auth": {"auth_header_name": "authorization"},
"version_data": {
"not_versioned": true,
"versions": {
"v1": {
"name": "v1"
}
"v1": {"name": "v1"}
}
},
"event_handlers": {
"events": {
"AuthFailure": [
{
"handler_name":"cp_dynamic_handler",
"handler_meta": {
"name": "my_handler"
}
}
]
}
"events": {"AuthFailure": [{
"handler_name":"cp_dynamic_handler",
"handler_meta": {
"name": "my_handler"
}
}]}
},
"custom_middleware": {
"pre": [
{
"name": "MyPreMiddleware"
}
],
"pre": [{"name": "MyPreMiddleware"}],
"driver": "python"
},
"proxy": {
Expand All @@ -306,30 +293,21 @@ const basicCoProcessDef = `{

const protectedCoProcessDef = `{
"api_id": "1",
"org_id": "default",
"auth": {
"auth_header_name": "authorization"
},
"auth": {"auth_header_name": "authorization"},
"enable_coprocess_auth": true,
"version_data": {
"not_versioned": true,
"versions": {
"v1": {
"name": "v1"
}
"v1": {"name": "v1"}
}
},
"event_handlers": {
"events": {
"AuthFailure": [
{
"handler_name":"cp_dynamic_handler",
"handler_meta": {
"name": "my_handler"
}
}
]
}
"events": {"AuthFailure": [{
"handler_name":"cp_dynamic_handler",
"handler_meta": {
"name": "my_handler"
}
}]}
},
"custom_middleware": {
"auth_check": {
Expand Down
8 changes: 2 additions & 6 deletions extended_method_versioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ const nonExpiringExtendedDef = `{
"location": "header",
"key": "version"
},
"auth": {
"auth_header_name": "authorization"
},
"auth": {"auth_header_name": "authorization"},
"version_data": {
"versions": {
"v1": {
Expand Down Expand Up @@ -135,9 +133,7 @@ const nonExpiringExtendedDefNoWhitelist = `{
"location": "header",
"key": "version"
},
"auth": {
"auth_header_name": "authorization"
},
"auth": {"auth_header_name": "authorization"},
"version_data": {
"versions": {
"v1": {
Expand Down
Loading

0 comments on commit 3f1e6c4

Please sign in to comment.