Skip to content

Commit

Permalink
More test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
strideynet committed Jan 10, 2025
1 parent d7b3fbb commit 3289501
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions lib/auth/machineid/workloadidentityv1/decision_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,66 @@ func Test_evaluateRules(t *testing.T) {
attrs: attrs,
requireErr: noMatchRule,
},
{
name: "not_in: pass",
wid: &workloadidentityv1pb.WorkloadIdentity{
Kind: types.KindWorkloadIdentity,
Version: types.V1,
Metadata: &headerv1.Metadata{
Name: "test",
},
Spec: &workloadidentityv1pb.WorkloadIdentitySpec{
Rules: &workloadidentityv1pb.WorkloadIdentityRules{
Allow: []*workloadidentityv1pb.WorkloadIdentityRule{
{
Conditions: []*workloadidentityv1pb.WorkloadIdentityCondition{
{
Attribute: "user.name",
Operator: &workloadidentityv1pb.WorkloadIdentityCondition_NotIn{
NotIn: &workloadidentityv1pb.WorkloadIdentityConditionNotIn{
Values: []string{"bar", "fizz"},
},
},
},
},
},
},
},
},
},
attrs: attrs,
requireErr: require.NoError,
},
{
name: "in: fail",
wid: &workloadidentityv1pb.WorkloadIdentity{
Kind: types.KindWorkloadIdentity,
Version: types.V1,
Metadata: &headerv1.Metadata{
Name: "test",
},
Spec: &workloadidentityv1pb.WorkloadIdentitySpec{
Rules: &workloadidentityv1pb.WorkloadIdentityRules{
Allow: []*workloadidentityv1pb.WorkloadIdentityRule{
{
Conditions: []*workloadidentityv1pb.WorkloadIdentityCondition{
{
Attribute: "user.name",
Operator: &workloadidentityv1pb.WorkloadIdentityCondition_NotIn{
NotIn: &workloadidentityv1pb.WorkloadIdentityConditionNotIn{
Values: []string{"bar", "foo"},
},
},
},
},
},
},
},
},
},
attrs: attrs,
requireErr: noMatchRule,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 3289501

Please sign in to comment.