Skip to content

Commit 9bafdb4

Browse files
authored
chore: remove unused code (#6674)
1 parent 5c29229 commit 9bafdb4

File tree

2 files changed

+0
-71
lines changed

2 files changed

+0
-71
lines changed

internal/admission/validation/consumers/credentials/validation.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -71,24 +71,6 @@ func ValidateCredentials(secret *corev1.Secret) error {
7171
return nil
7272
}
7373

74-
// IsKeyUniqueConstrained indicates whether or not a given key and its type there
75-
// are unique constraints in place.
76-
func IsKeyUniqueConstrained(keyType, key string) (constrained bool) {
77-
constrainedKeys, credTypeHasConstraints := uniqueKeyConstraints[keyType]
78-
if !credTypeHasConstraints {
79-
return
80-
}
81-
82-
for _, constrainedKey := range constrainedKeys {
83-
if key == constrainedKey {
84-
constrained = true
85-
return
86-
}
87-
}
88-
89-
return
90-
}
91-
9274
// -----------------------------------------------------------------------------
9375
// Validation - Credentials
9476
// -----------------------------------------------------------------------------

internal/admission/validation/consumers/credentials/validation_test.go

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -12,59 +12,6 @@ import (
1212
"github.com/kong/kubernetes-ingress-controller/v3/internal/labels"
1313
)
1414

15-
func TestUniqueConstraintsValidation(t *testing.T) {
16-
t.Log("Setting up an index of existing credentials which have unique constraints")
17-
index := make(Index)
18-
require.NoError(t, index.add(Credential{
19-
Key: "username",
20-
Value: "batman",
21-
Type: "basic-auth",
22-
}))
23-
require.NoError(t, index.add(Credential{
24-
Key: "username",
25-
Value: "robin",
26-
Type: "basic-auth",
27-
}))
28-
29-
t.Log("Verifying that a new basic-auth credential with a unique username doesn't violate constraints")
30-
nonviolatingCredential := Credential{
31-
Key: "username",
32-
Value: "nightwing",
33-
Type: "basic-auth",
34-
}
35-
assert.NoError(t, index.add(nonviolatingCredential))
36-
37-
t.Log("Verifying that a new basic-auth credential with a username that's already in use violates constraints")
38-
violatingCredential := Credential{
39-
Key: "username",
40-
Value: "batman",
41-
Type: "basic-auth",
42-
}
43-
assert.True(t, IsKeyUniqueConstrained(violatingCredential.Type, violatingCredential.Key))
44-
err := index.add(violatingCredential)
45-
assert.Error(t, err)
46-
47-
t.Log("Setting up a list of existing credentials which have no unique constraints")
48-
index = make(Index)
49-
assert.NoError(t, index.add(Credential{
50-
Key: "key",
51-
Value: "test",
52-
Type: "acl",
53-
}))
54-
55-
t.Log("Verifying that non-unique constrained credentials don't trigger a violation")
56-
duplicate := Credential{
57-
Key: "key",
58-
Value: "test",
59-
Type: "acl",
60-
}
61-
assert.False(t, IsKeyUniqueConstrained(duplicate.Type, duplicate.Key))
62-
assert.NoError(t, index.add(duplicate))
63-
64-
t.Log("Verifying that unconstrained keys for types with constraints don't flag as violated")
65-
assert.False(t, IsKeyUniqueConstrained("basic-auth", "unconstrained-key"))
66-
}
67-
6815
func TestValidateCredentials(t *testing.T) {
6916
tests := []struct {
7017
name string

0 commit comments

Comments
 (0)