Skip to content

Commit

Permalink
Additional test cases to raise test coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Ed Snible <[email protected]>
  • Loading branch information
esnible committed Jul 5, 2022
1 parent d7e2528 commit 4f449af
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/config/tenancy/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ func TestMetadataAnnotator(t *testing.T) {
tenancyConfig *TenancyConfig
requestHeaders map[string][]string
}{
{
name: "missing tenant",
tenancyConfig: NewTenancyConfig(&Options{Enabled: true}),
requestHeaders: map[string][]string{"x-tenant": {""}},
},
{
name: "tenanted",
tenancyConfig: NewTenancyConfig(&Options{Enabled: true}),
Expand Down
6 changes: 6 additions & 0 deletions pkg/config/tenancy/interceptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ func TestTenancyInterceptor(t *testing.T) {
ctx: metadata.NewIncomingContext(context.Background(), map[string][]string{"x-tenant": {"acme"}}),
errMsg: "",
},
{
name: "extra tenant header",
tenancyConfig: NewTenancyConfig(&Options{Enabled: true, Tenants: []string{"acme"}}),
ctx: metadata.NewIncomingContext(context.Background(), map[string][]string{"x-tenant": {"acme", "megacorp"}}),
errMsg: "rpc error: code = PermissionDenied desc = extra tenant header",
},
}

for _, test := range tests {
Expand Down

0 comments on commit 4f449af

Please sign in to comment.