Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v15] Ignore AccessListsMember's IneligibleStatus field #41050

Merged
merged 2 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/services/compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ func CompareResources[T any](resA, resB T) int {
cmpopts.IgnoreFields(types.UserSpecV2{}, "Status"),
cmpopts.IgnoreFields(accesslist.AccessList{}, "Status"),
cmpopts.IgnoreUnexported(headerv1.Metadata{}),
// Managed by IneligibleStatusReconciler, ignored by all others.
cmpopts.IgnoreFields(accesslist.AccessListMemberSpec{}, "IneligibleStatus"),
cmpopts.EquateEmpty(),
)
}
Expand Down
13 changes: 13 additions & 0 deletions lib/services/compare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"testing"

"github.com/stretchr/testify/require"

"github.com/gravitational/teleport/api/types/accesslist"
)

func TestCompareResources(t *testing.T) {
Expand All @@ -31,6 +33,17 @@ func TestCompareResources(t *testing.T) {
// These results should be forced since we're going through a custom compare function.
compareTestCase(t, "IsEqual equal", &compareResourceWithEqual{true}, &compareResourceWithEqual{false}, Equal)
compareTestCase(t, "IsEqual not equal", &compareResourceWithEqual{false}, &compareResourceWithEqual{false}, Different)

// These results compare AccessListMemberSpec, which should ignore the IneligibleStatus field.
newAccessListMemberSpec := func(ineligibleStatus, accessList string) accesslist.AccessListMemberSpec {
return accesslist.AccessListMemberSpec{
AccessList: accessList,
IneligibleStatus: ineligibleStatus,
}
}
compareTestCase(t, "cmp equal with equal IneligibleStatus", newAccessListMemberSpec("status1", "accessList1"), newAccessListMemberSpec("status1", "accessList1"), Equal)
compareTestCase(t, "cmp equal with different IneligibleStatus", newAccessListMemberSpec("status1", "accessList1"), newAccessListMemberSpec("status2", "accessList1"), Equal)
compareTestCase(t, "cmp not equal", newAccessListMemberSpec("status1", "accessList1"), newAccessListMemberSpec("status1", "accessList2"), Different)
}

func compareTestCase[T any](t *testing.T, name string, resA, resB T, expected int) {
Expand Down
Loading