Skip to content

Commit

Permalink
Add status to organization membership and updated event (#305)
Browse files Browse the repository at this point in the history
* Add status to organization membership

* Fix test errors and format

* Bump ubuntu version for CI
  • Loading branch information
blairworkos authored Mar 8, 2024
1 parent 363c896 commit 6b3f9d0
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: workos-go pipeline
agent:
machine:
type: e1-standard-2
os_image: ubuntu1804
os_image: ubuntu2004

blocks:
- name: Check code style
Expand Down
1 change: 1 addition & 0 deletions pkg/events/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const (
UserUpdated = "user.updated"
UserDeleted = "user.deleted"
OrganizationMembershipAdded = "organization_membership.added"
OrganizationMembershipUpdated = "organization_membership.updated"
OrganizationMembershipRemoved = "organization_membership.removed"
)

Expand Down
12 changes: 12 additions & 0 deletions pkg/usermanagement/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ type Organization struct {
Name string `json:"name"`
}

// OrganizationMembershipStatus represents the status of an Organization Membership.
type OrganizationMembershipStatus string

// Constants that enumerate the status of an Organization Membership.
const (
Active OrganizationMembershipStatus = "active"
PendingOrganizationMembership OrganizationMembershipStatus = "pending"
)

// OrganizationMembership contains data about a particular OrganizationMembership.
type OrganizationMembership struct {
// The Organization Membership's unique identifier.
Expand All @@ -73,6 +82,9 @@ type OrganizationMembership struct {
// The ID of the Organization.
OrganizationID string `json:"organization_id"`

// The Status of the Organization.
Status OrganizationMembershipStatus `json:"status"`

// CreatedAt is the timestamp of when the OrganizationMembership was created.
CreatedAt string `json:"created_at"`

Expand Down
7 changes: 7 additions & 0 deletions pkg/usermanagement/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1538,6 +1538,7 @@ func TestGetOrganizationMembership(t *testing.T) {
ID: "om_01E4ZCR3C56J083X43JQXF3JK5",
UserID: "user_01E4ZCR3C5A4QZ2Z2JQXGKZJ9E",
OrganizationID: "org_01E4ZCR3C56J083X43JQXF3JK5",
Status: Active,
CreatedAt: "2021-06-25T19:07:33.155Z",
UpdatedAt: "2021-06-25T19:07:33.155Z",
},
Expand Down Expand Up @@ -1579,6 +1580,7 @@ func getOrganizationMembershipTestHandler(w http.ResponseWriter, r *http.Request
ID: "om_01E4ZCR3C56J083X43JQXF3JK5",
UserID: "user_01E4ZCR3C5A4QZ2Z2JQXGKZJ9E",
OrganizationID: "org_01E4ZCR3C56J083X43JQXF3JK5",
Status: Active,
CreatedAt: "2021-06-25T19:07:33.155Z",
UpdatedAt: "2021-06-25T19:07:33.155Z",
})
Expand Down Expand Up @@ -1609,6 +1611,7 @@ func TestListOrganizationMemberships(t *testing.T) {
ID: "om_01E4ZCR3C56J083X43JQXF3JK5",
UserID: "user_01E4ZCR3C5A4QZ2Z2JQXGKZJ9E",
OrganizationID: "org_01E4ZCR3C56J083X43JQXF3JK5",
Status: Active,
CreatedAt: "2021-06-25T19:07:33.155Z",
UpdatedAt: "2021-06-25T19:07:33.155Z",
},
Expand Down Expand Up @@ -1642,6 +1645,7 @@ func TestListOrganizationMemberships(t *testing.T) {
ID: "om_01E4ZCR3C56J083X43JQXF3JK5",
UserID: "user_01E4ZCR3C5A4QZ2Z2JQXGKZJ9E",
OrganizationID: "org_01E4ZCR3C56J083X43JQXF3JK5",
Status: Active,
CreatedAt: "2021-06-25T19:07:33.155Z",
UpdatedAt: "2021-06-25T19:07:33.155Z",
},
Expand Down Expand Up @@ -1686,6 +1690,7 @@ func listOrganizationMembershipsTestHandler(w http.ResponseWriter, r *http.Reque
ID: "om_01E4ZCR3C56J083X43JQXF3JK5",
UserID: "user_01E4ZCR3C5A4QZ2Z2JQXGKZJ9E",
OrganizationID: "org_01E4ZCR3C56J083X43JQXF3JK5",
Status: Active,
CreatedAt: "2021-06-25T19:07:33.155Z",
UpdatedAt: "2021-06-25T19:07:33.155Z",
},
Expand Down Expand Up @@ -1729,6 +1734,7 @@ func TestCreateOrganizationMembership(t *testing.T) {
ID: "om_01E4ZCR3C56J083X43JQXF3JK5",
UserID: "user_01E4ZCR3C5A4QZ2Z2JQXGKZJ9E",
OrganizationID: "org_01E4ZCR3C56J083X43JQXF3JK5",
Status: Active,
CreatedAt: "2021-06-25T19:07:33.155Z",
UpdatedAt: "2021-06-25T19:07:33.155Z",
},
Expand Down Expand Up @@ -1770,6 +1776,7 @@ func createOrganizationMembershipTestHandler(w http.ResponseWriter, r *http.Requ
ID: "om_01E4ZCR3C56J083X43JQXF3JK5",
UserID: "user_01E4ZCR3C5A4QZ2Z2JQXGKZJ9E",
OrganizationID: "org_01E4ZCR3C56J083X43JQXF3JK5",
Status: Active,
CreatedAt: "2021-06-25T19:07:33.155Z",
UpdatedAt: "2021-06-25T19:07:33.155Z",
})
Expand Down
3 changes: 3 additions & 0 deletions pkg/usermanagement/usermanagement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ func TestUserManagementGetOrganizationMembership(t *testing.T) {
ID: "om_01E4ZCR3C56J083X43JQXF3JK5",
UserID: "user_01E4ZCR3C5A4QZ2Z2JQXGKZJ9E",
OrganizationID: "org_01E4ZCR3C56J083X43JQXF3JK5",
Status: Active,
CreatedAt: "2021-06-25T19:07:33.155Z",
UpdatedAt: "2021-06-25T19:07:33.155Z",
}
Expand Down Expand Up @@ -570,6 +571,7 @@ func TestUserManagementListOrganizationMemberships(t *testing.T) {
ID: "om_01E4ZCR3C56J083X43JQXF3JK5",
UserID: "user_01E4ZCR3C5A4QZ2Z2JQXGKZJ9E",
OrganizationID: "org_01E4ZCR3C56J083X43JQXF3JK5",
Status: Active,
CreatedAt: "2021-06-25T19:07:33.155Z",
UpdatedAt: "2021-06-25T19:07:33.155Z",
},
Expand Down Expand Up @@ -597,6 +599,7 @@ func TestUserManagementCreateOrganizationMembership(t *testing.T) {
ID: "om_01E4ZCR3C56J083X43JQXF3JK5",
UserID: "user_01E4ZCR3C5A4QZ2Z2JQXGKZJ9E",
OrganizationID: "org_01E4ZCR3C56J083X43JQXF3JK5",
Status: Active,
CreatedAt: "2021-06-25T19:07:33.155Z",
UpdatedAt: "2021-06-25T19:07:33.155Z",
}
Expand Down

0 comments on commit 6b3f9d0

Please sign in to comment.