Skip to content

Commit

Permalink
Merge pull request #411 from okta/OKTA-663100-orgurl-malformed
Browse files Browse the repository at this point in the history
fix orgurl malformed
  • Loading branch information
duytiennguyen-okta authored Oct 30, 2023
2 parents 7bb75d0 + edbaa30 commit 621d4ee
Show file tree
Hide file tree
Showing 14 changed files with 200 additions and 198 deletions.
84 changes: 42 additions & 42 deletions .generator/templates/api_application_test.go

Large diffs are not rendered by default.

50 changes: 25 additions & 25 deletions .generator/templates/api_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func setupGroup(name string) (*Group, *APIResponse, error) {
req := apiClient.GroupApi.CreateGroup(apiClient.cfg.Context)
req := apiClient.GroupAPI.CreateGroup(apiClient.cfg.Context)
gp := NewGroupProfile()
gp.SetName(name)
payload := Group{Profile: gp}
Expand All @@ -17,20 +17,20 @@ func setupGroup(name string) (*Group, *APIResponse, error) {
}

func cleanUpGroup(groupId string) (err error) {
_, err = apiClient.GroupApi.DeleteGroup(apiClient.cfg.Context, groupId).Execute()
_, err = apiClient.GroupAPI.DeleteGroup(apiClient.cfg.Context, groupId).Execute()
return
}

func cleanUpGroupRule(groupRuleId string) (err error) {
_, err = apiClient.GroupApi.DeleteGroupRule(apiClient.cfg.Context, groupRuleId).Execute()
_, err = apiClient.GroupAPI.DeleteGroupRule(apiClient.cfg.Context, groupRuleId).Execute()
return
}

func Test_Get_Group(t *testing.T) {
group, _, err := setupGroup(randomTestString())
require.NoError(t, err, "Creating a new group should not error")
t.Run("get group by id", func(t *testing.T) {
gid, _, err := apiClient.GroupApi.GetGroup(apiClient.cfg.Context, group.GetId()).Execute()
gid, _, err := apiClient.GroupAPI.GetGroup(apiClient.cfg.Context, group.GetId()).Execute()
require.NoError(t, err, "Could not get group by ID")
assert.Equal(t, group.GetId(), gid.GetId())
})
Expand All @@ -42,7 +42,7 @@ func Test_Get_List_Group(t *testing.T) {
group, _, err := setupGroup(randomTestString())
require.NoError(t, err, "Creating a new group should not error")
t.Run("get list group", func(t *testing.T) {
gs, _, err := apiClient.GroupApi.ListGroups(apiClient.cfg.Context).Execute()
gs, _, err := apiClient.GroupAPI.ListGroups(apiClient.cfg.Context).Execute()
require.NoError(t, err, "Could not get list group")
var createdGroupInList bool
for _, g := range gs {
Expand All @@ -61,7 +61,7 @@ func Test_Search_Group(t *testing.T) {
group, _, err := setupGroup(groupName)
require.NoError(t, err, "Creating a new group should not error")
t.Run("search group", func(t *testing.T) {
req := apiClient.GroupApi.ListGroups(apiClient.cfg.Context)
req := apiClient.GroupAPI.ListGroups(apiClient.cfg.Context)
req = req.Q(groupName)
gs, _, err := req.Execute()
require.NoError(t, err, "Could not get result from search keyword")
Expand All @@ -87,7 +87,7 @@ func Test_Update_Group(t *testing.T) {
ngp.SetName(newGroupName)
ng := Group{}
ng.SetProfile(ngp)
req := apiClient.GroupApi.ReplaceGroup(apiClient.cfg.Context, group.GetId())
req := apiClient.GroupAPI.ReplaceGroup(apiClient.cfg.Context, group.GetId())
req = req.Group(ng)
g, _, err := req.Execute()
require.NoError(t, err, "Could not update group")
Expand All @@ -104,9 +104,9 @@ func Test_Group_User_Operation(t *testing.T) {
user, _, _, err := setupUser(true)
require.NoError(t, err, "Creating a new user should not error")
t.Run("add user to group", func(t *testing.T) {
_, err := apiClient.GroupApi.AssignUserToGroup(apiClient.cfg.Context, group.GetId(), user.GetId()).Execute()
_, err := apiClient.GroupAPI.AssignUserToGroup(apiClient.cfg.Context, group.GetId(), user.GetId()).Execute()
require.NoError(t, err, "Could not add user to group")
users, _, err := apiClient.GroupApi.ListGroupUsers(apiClient.cfg.Context, group.GetId()).Execute()
users, _, err := apiClient.GroupAPI.ListGroupUsers(apiClient.cfg.Context, group.GetId()).Execute()
require.NoError(t, err)
found := false
for _, u := range users {
Expand All @@ -117,9 +117,9 @@ func Test_Group_User_Operation(t *testing.T) {
assert.True(t, found, "Could not find user in group")
})
t.Run("remove user from group", func(t *testing.T) {
_, err := apiClient.GroupApi.UnassignUserFromGroup(apiClient.cfg.Context, group.GetId(), user.GetId()).Execute()
_, err := apiClient.GroupAPI.UnassignUserFromGroup(apiClient.cfg.Context, group.GetId(), user.GetId()).Execute()
require.NoError(t, err, "Could not remove user from group")
users, _, err := apiClient.GroupApi.ListGroupUsers(apiClient.cfg.Context, group.GetId()).Execute()
users, _, err := apiClient.GroupAPI.ListGroupUsers(apiClient.cfg.Context, group.GetId()).Execute()
require.NoError(t, err)
found := false
for _, u := range users {
Expand Down Expand Up @@ -154,14 +154,14 @@ func Test_Group_Rule_Operation(t *testing.T) {
gr.SetConditions(*grc)
gr.SetType("group_rule")
gr.SetName(randomTestString())
req := apiClient.GroupApi.CreateGroupRule(apiClient.cfg.Context)
req := apiClient.GroupAPI.CreateGroupRule(apiClient.cfg.Context)
req = req.GroupRule(*gr)
groupRule, _, err := req.Execute()
require.NoError(t, err, "Creating a new group rule should not error")
t.Run("activate group rule", func(t *testing.T) {
_, err = apiClient.GroupApi.ActivateGroupRule(apiClient.cfg.Context, groupRule.GetId()).Execute()
_, err = apiClient.GroupAPI.ActivateGroupRule(apiClient.cfg.Context, groupRule.GetId()).Execute()
require.NoError(t, err, "Should not error when activating rule")
groupRules, _, err := apiClient.GroupApi.ListGroupRules(apiClient.cfg.Context).Execute()
groupRules, _, err := apiClient.GroupAPI.ListGroupRules(apiClient.cfg.Context).Execute()
require.NoError(t, err, "Should not error when listing group rule")
found := false
for _, grs := range groupRules {
Expand All @@ -172,7 +172,7 @@ func Test_Group_Rule_Operation(t *testing.T) {
assert.True(t, found, "Found group rule in list")
})
t.Run("deactivate group rule", func(t *testing.T) {
_, err = apiClient.GroupApi.DeactivateGroupRule(apiClient.cfg.Context, groupRule.GetId()).Execute()
_, err = apiClient.GroupAPI.DeactivateGroupRule(apiClient.cfg.Context, groupRule.GetId()).Execute()
require.NoError(t, err, "Should not error when deactivating rule")
})
t.Run("update group rule", func(t *testing.T) {
Expand All @@ -190,13 +190,13 @@ func Test_Group_Rule_Operation(t *testing.T) {
gr.SetConditions(*grc)
gr.SetType("group_rule")
gr.SetName(randomTestString())
req := apiClient.GroupApi.ReplaceGroupRule(apiClient.cfg.Context, groupRule.GetId())
req := apiClient.GroupAPI.ReplaceGroupRule(apiClient.cfg.Context, groupRule.GetId())
req = req.GroupRule(*gr)
newGroupRule, _, err := req.Execute()
require.NoError(t, err, "Should not error when updating rule")
_, err = apiClient.GroupApi.ActivateGroupRule(apiClient.cfg.Context, newGroupRule.GetId()).Execute()
_, err = apiClient.GroupAPI.ActivateGroupRule(apiClient.cfg.Context, newGroupRule.GetId()).Execute()
require.NoError(t, err, "Should not error when activating rule")
_, err = apiClient.GroupApi.DeactivateGroupRule(apiClient.cfg.Context, groupRule.GetId()).Execute()
_, err = apiClient.GroupAPI.DeactivateGroupRule(apiClient.cfg.Context, groupRule.GetId()).Execute()
require.NoError(t, err, "Should not error when deactivating rule")
})
err = cleanUpUser(user.GetId())
Expand All @@ -212,16 +212,16 @@ func Test_List_Assigned_Applications_For_Group(t *testing.T) {
require.NoError(t, err, "Creating a new group should not error")
var createdApp *ListApplications200ResponseInner
t.Run("get list assigned application for group", func(t *testing.T) {
apps, _, err := apiClient.GroupApi.ListAssignedApplicationsForGroup(apiClient.cfg.Context, group.GetId()).Execute()
apps, _, err := apiClient.GroupAPI.ListAssignedApplicationsForGroup(apiClient.cfg.Context, group.GetId()).Execute()
require.NoError(t, err, "Should not error when listing assigned apps for group")
assert.Equal(t, 0, len(apps), "there shouldn't be any apps assigned to group")
createdApp, _, err = setupBookmarkApplication(randomTestString())
require.NoError(t, err, "Creating an application should not error")
aareq := apiClient.ApplicationGroupsApi.AssignGroupToApplication(apiClient.cfg.Context, createdApp.BookmarkApplication.GetId(), group.GetId())
aareq := apiClient.ApplicationGroupsAPI.AssignGroupToApplication(apiClient.cfg.Context, createdApp.BookmarkApplication.GetId(), group.GetId())
aareq.applicationGroupAssignment = NewApplicationGroupAssignment()
_, _, err = aareq.Execute()
require.NoError(t, err, "Assigning application to group should not error")
apps, _, err = apiClient.GroupApi.ListAssignedApplicationsForGroup(apiClient.cfg.Context, group.GetId()).Execute()
apps, _, err = apiClient.GroupAPI.ListAssignedApplicationsForGroup(apiClient.cfg.Context, group.GetId()).Execute()
require.NoError(t, err, "Should not error when listing assigned apps for group")
assert.Equal(t, 1, len(apps), "there shouldn't be any apps assigned to group")
})
Expand All @@ -236,13 +236,13 @@ func Test_Assigned_Role_To_Group_Operation(t *testing.T) {
require.NoError(t, err, "Creating a new group should not error")
var createdRole *Role
t.Run("assigned role to group", func(t *testing.T) {
req := apiClient.RoleAssignmentApi.AssignRoleToGroup(apiClient.cfg.Context, group.GetId())
req := apiClient.RoleAssignmentAPI.AssignRoleToGroup(apiClient.cfg.Context, group.GetId())
assignedRoleSA := NewAssignRoleRequest()
assignedRoleSA.SetType("SUPER_ADMIN")
req = req.AssignRoleRequest(*assignedRoleSA)
createdRole, _, err = req.Execute()
require.NoError(t, err, "Assigned role to group should not error")
roles, _, err := apiClient.RoleAssignmentApi.ListGroupAssignedRoles(apiClient.cfg.Context, group.GetId()).Execute()
roles, _, err := apiClient.RoleAssignmentAPI.ListGroupAssignedRoles(apiClient.cfg.Context, group.GetId()).Execute()
require.NoError(t, err, "Listing group assigned role should not error")
var found bool
for _, r := range roles {
Expand All @@ -253,9 +253,9 @@ func Test_Assigned_Role_To_Group_Operation(t *testing.T) {
assert.True(t, found)
})
t.Run("unassigned role to group", func(t *testing.T) {
_, err = apiClient.RoleAssignmentApi.UnassignRoleFromGroup(apiClient.cfg.Context, group.GetId(), createdRole.GetId()).Execute()
_, err = apiClient.RoleAssignmentAPI.UnassignRoleFromGroup(apiClient.cfg.Context, group.GetId(), createdRole.GetId()).Execute()
require.NoError(t, err, "Unassigned role to group should not error")
roles, _, err := apiClient.RoleAssignmentApi.ListGroupAssignedRoles(apiClient.cfg.Context, group.GetId()).Execute()
roles, _, err := apiClient.RoleAssignmentAPI.ListGroupAssignedRoles(apiClient.cfg.Context, group.GetId()).Execute()
require.NoError(t, err, "Listing group assigned role should not error")
assert.Empty(t, roles)
})
Expand Down
Loading

0 comments on commit 621d4ee

Please sign in to comment.