-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: add support for canonical representation
- Loading branch information
Showing
22 changed files
with
735 additions
and
54 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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package accesslog_test | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/ginkgo/extensions/table" | ||
. "github.com/onsi/gomega" | ||
|
||
. "github.com/Kong/kuma/pkg/envoy/accesslog" | ||
) | ||
|
||
var _ = Describe("DynamicMetadataFormatter", func() { | ||
|
||
Describe("String()", func() { | ||
type testCase struct { | ||
filterNamespace string | ||
path []string | ||
maxLength int | ||
expected string | ||
} | ||
|
||
DescribeTable("should return correct canonical representation", | ||
func(given testCase) { | ||
// setup | ||
formatter := &DynamicMetadataFormatter{FilterNamespace: given.filterNamespace, Path: given.path, MaxLength: given.maxLength} | ||
|
||
// when | ||
actual := formatter.String() | ||
// then | ||
Expect(actual).To(Equal(given.expected)) | ||
|
||
}, | ||
Entry("%DYNAMIC_METADATA()%", testCase{ | ||
expected: `%DYNAMIC_METADATA()%`, | ||
}), | ||
Entry("%DYNAMIC_METADATA():10%", testCase{ | ||
maxLength: 10, | ||
expected: `%DYNAMIC_METADATA():10%`, | ||
}), | ||
Entry("%DYNAMIC_METADATA(com.test.my_filter)%", testCase{ | ||
filterNamespace: "com.test.my_filter", | ||
expected: `%DYNAMIC_METADATA(com.test.my_filter)%`, | ||
}), | ||
Entry("%DYNAMIC_METADATA(com.test.my_filter):10%", testCase{ | ||
filterNamespace: "com.test.my_filter", | ||
maxLength: 10, | ||
expected: `%DYNAMIC_METADATA(com.test.my_filter):10%`, | ||
}), | ||
Entry("%DYNAMIC_METADATA(com.test.my_filter:test_object)%", testCase{ | ||
filterNamespace: "com.test.my_filter", | ||
path: []string{"test_object"}, | ||
expected: `%DYNAMIC_METADATA(com.test.my_filter:test_object)%`, | ||
}), | ||
Entry("%DYNAMIC_METADATA(com.test.my_filter:test_object):10%", testCase{ | ||
filterNamespace: "com.test.my_filter", | ||
path: []string{"test_object"}, | ||
maxLength: 10, | ||
expected: `%DYNAMIC_METADATA(com.test.my_filter:test_object):10%`, | ||
}), | ||
Entry("%DYNAMIC_METADATA(com.test.my_filter:test_object:inner_key)%", testCase{ | ||
filterNamespace: "com.test.my_filter", | ||
path: []string{"test_object", "inner_key"}, | ||
expected: `%DYNAMIC_METADATA(com.test.my_filter:test_object:inner_key)%`, | ||
}), | ||
Entry("%DYNAMIC_METADATA(com.test.my_filter:test_object:inner_key):10%", testCase{ | ||
filterNamespace: "com.test.my_filter", | ||
path: []string{"test_object", "inner_key"}, | ||
maxLength: 10, | ||
expected: `%DYNAMIC_METADATA(com.test.my_filter:test_object:inner_key):10%`, | ||
}), | ||
Entry("%DYNAMIC_METADATA(:test_object:inner_key)%", testCase{ | ||
path: []string{"test_object", "inner_key"}, | ||
expected: `%DYNAMIC_METADATA(:test_object:inner_key)%`, | ||
}), | ||
Entry("%DYNAMIC_METADATA(:test_object:inner_key):10%", testCase{ | ||
path: []string{"test_object", "inner_key"}, | ||
maxLength: 10, | ||
expected: `%DYNAMIC_METADATA(:test_object:inner_key):10%`, | ||
}), | ||
) | ||
}) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package accesslog_test | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/ginkgo/extensions/table" | ||
. "github.com/onsi/gomega" | ||
|
||
. "github.com/Kong/kuma/pkg/envoy/accesslog" | ||
) | ||
|
||
var _ = Describe("FilterStateFormatter", func() { | ||
|
||
Describe("String()", func() { | ||
type testCase struct { | ||
key string | ||
maxLength int | ||
expected string | ||
} | ||
|
||
DescribeTable("should return correct canonical representation", | ||
func(given testCase) { | ||
// setup | ||
formatter := &FilterStateFormatter{Key: given.key, MaxLength: given.maxLength} | ||
|
||
// when | ||
actual := formatter.String() | ||
// then | ||
Expect(actual).To(Equal(given.expected)) | ||
|
||
}, | ||
Entry("%FILTER_STATE()%", testCase{ | ||
expected: `%FILTER_STATE()%`, | ||
}), | ||
Entry("%FILTER_STATE(filter.state.key)%", testCase{ | ||
key: "filter.state.key", | ||
expected: `%FILTER_STATE(filter.state.key)%`, | ||
}), | ||
Entry("%FILTER_STATE(filter.state.key):10%", testCase{ | ||
key: "filter.state.key", | ||
maxLength: 10, | ||
expected: `%FILTER_STATE(filter.state.key):10%`, | ||
}), | ||
) | ||
}) | ||
}) |
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
Oops, something went wrong.