Skip to content

Commit

Permalink
imports more stable now
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Buhr committed Dec 19, 2014
1 parent fb584b6 commit 16fd20b
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 164 deletions.
5 changes: 5 additions & 0 deletions api_definition_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,11 @@ func (a *APISpec) IsURLAllowedAndIgnored(method, url string, RxPaths []URLSpec,

}

if WhiteListStatus {
// We have a whitelist, nothing gets through unless specifically defined
return EndPointNotAllowed, nil
}

// Method not matched in an extended set, means it can be passed through
return StatusOk, nil
}
Expand Down
88 changes: 0 additions & 88 deletions apps/bp.json

This file was deleted.

4 changes: 2 additions & 2 deletions blueprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ type BluePrintAST struct {
Description string `json:"description"`
Example string `json:"example"`
Name string `json:"name"`
Required string `json:"required"`
Required bool `json:"required"`
Type string `json:"type"`
Values []struct {
Value string `json:"value"`
Expand All @@ -99,7 +99,7 @@ type BluePrintAST struct {
Description string `json:"description"`
Example string `json:"example"`
Name string `json:"name"`
Required string `json:"required"`
Required bool `json:"required"`
Type string `json:"type"`
Values []struct {
Value string `json:"value"`
Expand Down
72 changes: 0 additions & 72 deletions blueprints/test.json

This file was deleted.

7 changes: 6 additions & 1 deletion command_mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,12 @@ func bluePrintLoadFile(filePath string) (*BluePrintAST, error) {
return thisBlueprint.(*BluePrintAST), err
}

thisBlueprint.ReadString(string(bluePrintFileData))
readErr := thisBlueprint.ReadString(string(bluePrintFileData))
if readErr != nil {
log.Error("Failed to decode object")
return thisBlueprint.(*BluePrintAST), readErr
}

return thisBlueprint.(*BluePrintAST), nil
}

Expand Down
102 changes: 101 additions & 1 deletion extended_method_versioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,106 @@ var nonExpiringExtendedDef string = `
`

var nonExpiringExtendedDefNoWhitelist string = `
{
"name": "Tyk Test API",
"api_id": "1",
"org_id": "default",
"definition": {
"location": "header",
"key": "version"
},
"auth": {
"auth_header_name": "authorization"
},
"version_data": {
"not_versioned": false,
"versions": {
"v1": {
"name": "v1",
"expires": "3000-01-02 15:04",
"paths": {
"ignored": [],
"white_list": [],
"black_list": []
},
"use_extended_paths": true,
"extended_paths": {
"ignored": [
{
"path": "/v1/ignored/noregex",
"method_actions": {
"GET": {
"action": "no_action",
"code": 200,
"data": "",
"headers": {
"x-tyk-override-test": "tyk-override",
"x-tyk-override-test-2": "tyk-override-2"
}
}
}
},
{
"path": "/v1/ignored/with_id/{id}",
"method_actions": {
"GET": {
"action": "no_action",
"code": 200,
"data": "",
"headers": {
"x-tyk-override-test": "tyk-override",
"x-tyk-override-test-2": "tyk-override-2"
}
}
}
}
],
"white_list": [],
"black_list": [
{
"path": "v1/disallowed/blacklist/literal",
"method_actions": {
"GET": {
"action": "no_action",
"code": 200,
"data": "",
"headers": {
"x-tyk-override-test": "tyk-override",
"x-tyk-override-test-2": "tyk-override-2"
}
}
}
},
{
"path": "v1/disallowed/blacklist/{id}",
"method_actions": {
"GET": {
"action": "no_action",
"code": 200,
"data": "",
"headers": {
"x-tyk-override-test": "tyk-override",
"x-tyk-override-test-2": "tyk-override-2"
}
}
}
}
]
}
}
}
},
"proxy": {
"listen_path": "/v1",
"target_url": "http://lonelycode.com",
"strip_listen_path": false
}
}
`

func TestExtendedBlacklistLinks(t *testing.T) {
uri := "v1/disallowed/blacklist/literal"
method := "GET"
Expand All @@ -159,7 +259,7 @@ func TestExtendedBlacklistLinks(t *testing.T) {
}
req.Header.Add("version", "v1")

thisSpec := createDefinitionFromString(nonExpiringExtendedDef)
thisSpec := createDefinitionFromString(nonExpiringExtendedDefNoWhitelist)

ok, status, _ := thisSpec.IsRequestValid(req)
if ok == true {
Expand Down

0 comments on commit 16fd20b

Please sign in to comment.