Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enhancement: Allow specification of gRPC request metadata keys to be …
…logged (#1202)
- Loading branch information
1 parent
6df6dd7
commit b4ba131
Showing
5 changed files
with
110 additions
and
15 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,44 @@ | ||
// Copyright 2021-2022 Zenauth Ltd. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//go:build tests | ||
// +build tests | ||
|
||
package audit | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestMkIncludeKeysMethod(t *testing.T) { | ||
testCases := []struct { | ||
key string | ||
expected bool | ||
}{ | ||
{ | ||
key: "a", | ||
expected: false, | ||
}, | ||
{ | ||
key: "b", | ||
expected: false, | ||
}, | ||
{ | ||
key: "c", | ||
expected: true, | ||
}, | ||
} | ||
|
||
excludedMetadataKeys := []string{"a", "b"} | ||
includedMetadataKeys := []string{"a", "c"} | ||
includeKeys := mkIncludeKeysMethod(excludedMetadataKeys, includedMetadataKeys) | ||
|
||
for _, tc := range testCases { | ||
t.Run(tc.key, func(t *testing.T) { | ||
actual := includeKeys(tc.key) | ||
require.Equal(t, tc.expected, actual) | ||
}) | ||
} | ||
} |
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