package utils import ( "testing" "github.com/stretchr/testify/assert" ) func TestFilterEdgeRoles(t *testing.T) { testCases := []struct { name string testcase []string expected []string }{ { name: "Test Case 1 - empty", testcase: []string{""}, expected: []string{}, }, { name: "Test Case 2 - non matching string", testcase: []string{"hello"}, expected: []string{}, }, { name: "Test Case 3 - mixture of BSL and Edge roles", testcase: []string{ "NEP_IDENTITY_VIEWER", "CORE_INVITE_CREATE", "IDENTITY_IT_ADMIN", "CORE_INVITE_VIEWER", "NEP_ENTERPRISE_VIEWER", "NEP_ENTERPRISE_GRANT_REVOKE_ENTERPRISE_UNIT", "NEP_ENTERPRISE_SUPER_ADMINISTRATOR", "NEP_IDENTITY_GROUP_REMOVE_MEMBERS", "NEP_ENTERPRISE_GRANT_ENTERPRISE_UNIT_GROUP", "NEP_ENTERPRISE_GRANT_REVOKE_ENTERPRISE_UNIT_GROUP", "NEP_IDENTITY_GROUP_ADD_MEMBERS", "CORE_INVITE_DELETE", "NEP_ENTERPRISE_SUPER_VIEWER", "CORE_INVITE_ADMIN", "NEP_ENTERPRISE_GRANT_ENTERPRISE_UNIT", "NEP_ENTERPRISE_GROUP_REMOVE_ENTERPRISE_UNITS", "IDENTITY_SITE_ADMIN", "NEP_ENTERPRISE_GROUP_VIEWER", "CORE_INVITE_RESCIND", "NEP_ENTERPRISE_GROUP_ADD_ENTERPRISE_UNITS", "NEP_IDENTITY_UPDATE", "NEP_ENTERPRISE_GRANT_VIEWER", "SITE_READ", "NEP_ORGANIZATION_VIEWER", "EDGE_ORG_ADMIN", }, expected: []string{"EDGE_ORG_ADMIN"}, }, { name: "Test Case 4 - only BSL roles", testcase: []string{ "NEP_IDENTITY_VIEWER", "CORE_INVITE_CREATE", "IDENTITY_IT_ADMIN", "CORE_INVITE_VIEWER", "NEP_ENTERPRISE_VIEWER", "NEP_ENTERPRISE_GRANT_REVOKE_ENTERPRISE_UNIT", "NEP_ENTERPRISE_SUPER_ADMINISTRATOR", "NEP_IDENTITY_GROUP_REMOVE_MEMBERS", "NEP_ENTERPRISE_GRANT_ENTERPRISE_UNIT_GROUP", "NEP_ENTERPRISE_GRANT_REVOKE_ENTERPRISE_UNIT_GROUP", "NEP_IDENTITY_GROUP_ADD_MEMBERS", "CORE_INVITE_DELETE", "NEP_ENTERPRISE_SUPER_VIEWER", "CORE_INVITE_ADMIN", "NEP_ENTERPRISE_GRANT_ENTERPRISE_UNIT", "NEP_ENTERPRISE_GROUP_REMOVE_ENTERPRISE_UNITS", "IDENTITY_SITE_ADMIN", "NEP_ENTERPRISE_GROUP_VIEWER", "CORE_INVITE_RESCIND", "NEP_ENTERPRISE_GROUP_ADD_ENTERPRISE_UNITS", "NEP_IDENTITY_UPDATE", "NEP_ENTERPRISE_GRANT_VIEWER", "SITE_READ", "NEP_ORGANIZATION_VIEWER", }, expected: []string{}, }, } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { actual := FilterEdgeRoles(tc.testcase) assert.EqualValues(t, tc.expected, actual) }) } }