forked from kevholditch/go-form3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
roles_test.go
83 lines (67 loc) · 2.34 KB
/
roles_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package form3
import (
"github.com/ewilde/go-form3/client/ace"
"github.com/ewilde/go-form3/client/roles"
"github.com/ewilde/go-form3/models"
"github.com/go-openapi/strfmt"
"testing"
)
func TestAccDeleteRole(t *testing.T) {
createResponse, err := auth.SecurityClient.Roles.PostRoles(roles.NewPostRolesParams().
WithRoleCreationRequest(&models.RoleCreation{
Data: &models.Role{
OrganisationID: organisationId,
Type: "roles",
ID: strfmt.UUID("f6679900-10d2-44a1-9a46-2d972f4bf457"),
Attributes: &models.RoleAttributes{
Name: "TestRole",
},
},
}))
assertNoErrorOccurred(err, t)
_, err = auth.SecurityClient.Roles.DeleteRolesRoleID(roles.NewDeleteRolesRoleIDParams().
WithRoleID(createResponse.Payload.Data.ID),
)
if err != nil {
t.Error(err)
}
_, err = auth.SecurityClient.Roles.GetRolesRoleID(roles.NewGetRolesRoleIDParams().
WithRoleID(createResponse.Payload.Data.ID))
assertStatusCode(err, t, 404)
}
func TestAccDeleteRoleAce(t *testing.T) {
createRoleResponse, err := auth.SecurityClient.Roles.PostRoles(roles.NewPostRolesParams().
WithRoleCreationRequest(&models.RoleCreation{
Data: &models.Role{
OrganisationID: organisationId,
Type: "roles",
ID: strfmt.UUID("f6679900-10d2-44a1-9a46-2d972f4bf457"),
Attributes: &models.RoleAttributes{
Name: "TestRole",
},
},
}))
assertNoErrorOccurred(err, t)
createAceResponse, err := auth.SecurityClient.Ace.PostRolesRoleIDAces(ace.NewPostRolesRoleIDAcesParams().
WithRoleID(createRoleResponse.Payload.Data.ID).
WithAceCreationRequest(&models.AceCreation{
Data: &models.Ace{
OrganisationID: organisationId,
Type: "roles",
ID: strfmt.UUID("ad7e4332-dc05-4fd1-a9de-e0b9ef0fc269"),
Attributes: &models.AceAttributes{
RoleID: createRoleResponse.Payload.Data.ID,
Action: "updated",
RecordType: "User",
},
},
}))
_, err = auth.SecurityClient.Ace.DeleteRolesRoleIDAcesAceID(ace.NewDeleteRolesRoleIDAcesAceIDParams().
WithRoleID(createAceResponse.Payload.Data.Attributes.RoleID).
WithAceID(createAceResponse.Payload.Data.ID))
assertNoErrorOccurred(err, t)
_, err = auth.SecurityClient.Roles.DeleteRolesRoleID(roles.NewDeleteRolesRoleIDParams().
WithRoleID(createRoleResponse.Payload.Data.ID),
)
assertNoErrorOccurred(err, t)
}