Skip to content
Open
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
18 changes: 18 additions & 0 deletions pkg/directorysync/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,24 @@ type UserGroup struct {

// The Group's Name.
Name string

// The Group's unique identifier assigned by the Directory Provider.
IdpID string `json:"idp_id"`

// The identifier of the Directory the group belongs to.
DirectoryID string `json:"directory_id"`

// The identifier for the Organization in which the Directory resides.
OrganizationID string `json:"organization_id"`

// The Group's created at date.
CreatedAt string `json:"created_at"`

// The Group's updated at date.
UpdatedAt string `json:"updated_at"`

// The Group's raw attributes in raw encoded JSON.
RawAttributes json.RawMessage `json:"raw_attributes"`
}

// UserState represents the active state of a Directory User.
Expand Down
48 changes: 36 additions & 12 deletions pkg/directorysync/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,15 @@ func TestListUsers(t *testing.T) {
},
Groups: []UserGroup{
UserGroup{
Object: "user_group_object",
ID: "directory_group_123",
Name: "Group Name",
Object: "user_group_object",
ID: "directory_group_123",
Name: "Group Name",
IdpID: "123",
DirectoryID: "456",
OrganizationID: "789",
CreatedAt: "2022-06-08T17:05:58.051Z",
UpdatedAt: "2022-06-08T17:05:58.051Z",
RawAttributes: json.RawMessage(`{"foo":"bar"}`),
},
},
State: Active,
Expand Down Expand Up @@ -123,9 +129,15 @@ func listUsersTestHandler(w http.ResponseWriter, r *http.Request) {
},
Groups: []UserGroup{
UserGroup{
Object: "user_group_object",
ID: "directory_group_123",
Name: "Group Name",
Object: "user_group_object",
ID: "directory_group_123",
Name: "Group Name",
IdpID: "123",
DirectoryID: "456",
OrganizationID: "789",
CreatedAt: "2022-06-08T17:05:58.051Z",
UpdatedAt: "2022-06-08T17:05:58.051Z",
RawAttributes: json.RawMessage(`{"foo":"bar"}`),
},
},
State: Active,
Expand Down Expand Up @@ -290,9 +302,15 @@ func TestGetUser(t *testing.T) {
},
Groups: []UserGroup{
UserGroup{
Object: "user_group_object",
ID: "directory_group_123",
Name: "Group Name",
Object: "user_group_object",
ID: "directory_group_123",
Name: "Group Name",
IdpID: "123",
DirectoryID: "456",
OrganizationID: "789",
CreatedAt: "2022-06-08T17:05:58.051Z",
UpdatedAt: "2022-06-08T17:05:58.051Z",
RawAttributes: json.RawMessage(`{"foo":"bar"}`),
},
},
State: Active,
Expand Down Expand Up @@ -350,9 +368,15 @@ func getUserTestHandler(w http.ResponseWriter, r *http.Request) {
},
Groups: []UserGroup{
UserGroup{
Object: "user_group_object",
ID: "directory_group_123",
Name: "Group Name",
Object: "user_group_object",
ID: "directory_group_123",
Name: "Group Name",
IdpID: "123",
DirectoryID: "456",
OrganizationID: "789",
CreatedAt: "2022-06-08T17:05:58.051Z",
UpdatedAt: "2022-06-08T17:05:58.051Z",
RawAttributes: json.RawMessage(`{"foo":"bar"}`),
},
},
State: Active,
Expand Down
72 changes: 54 additions & 18 deletions pkg/directorysync/directorysync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,15 @@ func TestDirectorySyncListUsers(t *testing.T) {
},
Groups: []UserGroup{
UserGroup{
Object: "user_group_object",
ID: "directory_group_123",
Name: "Group Name",
Object: "user_group_object",
ID: "directory_group_123",
Name: "Group Name",
IdpID: "123",
DirectoryID: "456",
OrganizationID: "789",
CreatedAt: "2022-06-08T17:05:58.051Z",
UpdatedAt: "2022-06-08T17:05:58.051Z",
RawAttributes: json.RawMessage(`{"foo":"bar"}`),
},
},
State: Active,
Expand Down Expand Up @@ -134,9 +140,15 @@ func TestDirectorySyncGetUser(t *testing.T) {
},
Groups: []UserGroup{
UserGroup{
Object: "user_group_object",
ID: "directory_group_123",
Name: "Group Name",
Object: "user_group_object",
ID: "directory_group_123",
Name: "Group Name",
IdpID: "123",
DirectoryID: "456",
OrganizationID: "789",
CreatedAt: "2022-06-08T17:05:58.051Z",
UpdatedAt: "2022-06-08T17:05:58.051Z",
RawAttributes: json.RawMessage(`{"foo":"bar"}`),
},
},
State: Active,
Expand Down Expand Up @@ -334,9 +346,15 @@ func TestPrimaryEmail(t *testing.T) {
},
Groups: []UserGroup{
UserGroup{
Object: "user_group_object",
ID: "directory_group_123",
Name: "Group Name",
Object: "user_group_object",
ID: "directory_group_123",
Name: "Group Name",
IdpID: "123",
DirectoryID: "456",
OrganizationID: "789",
CreatedAt: "2022-06-08T17:05:58.051Z",
UpdatedAt: "2022-06-08T17:05:58.051Z",
RawAttributes: json.RawMessage(`{"foo":"bar"}`),
},
},
State: Active,
Expand Down Expand Up @@ -366,9 +384,15 @@ func TestPrimaryEmail(t *testing.T) {
},
Groups: []UserGroup{
UserGroup{
Object: "user_group_object",
ID: "directory_group_123",
Name: "Group Name",
Object: "user_group_object",
ID: "directory_group_123",
Name: "Group Name",
IdpID: "123",
DirectoryID: "456",
OrganizationID: "789",
CreatedAt: "2022-06-08T17:05:58.051Z",
UpdatedAt: "2022-06-08T17:05:58.051Z",
RawAttributes: json.RawMessage(`{"foo":"bar"}`),
},
},
State: Active,
Expand All @@ -391,9 +415,15 @@ func TestPrimaryEmail(t *testing.T) {
},
Groups: []UserGroup{
UserGroup{
Object: "user_group_object",
ID: "directory_group_123",
Name: "Group Name",
Object: "user_group_object",
ID: "directory_group_123",
Name: "Group Name",
IdpID: "123",
DirectoryID: "456",
OrganizationID: "789",
CreatedAt: "2022-06-08T17:05:58.051Z",
UpdatedAt: "2022-06-08T17:05:58.051Z",
RawAttributes: json.RawMessage(`{"foo":"bar"}`),
},
},
State: Active,
Expand All @@ -410,9 +440,15 @@ func TestPrimaryEmail(t *testing.T) {
LastName: "Testz",
Groups: []UserGroup{
UserGroup{
Object: "user_group_object",
ID: "directory_group_123",
Name: "Group Name",
Object: "user_group_object",
ID: "directory_group_123",
Name: "Group Name",
IdpID: "123",
DirectoryID: "456",
OrganizationID: "789",
CreatedAt: "2022-06-08T17:05:58.051Z",
UpdatedAt: "2022-06-08T17:05:58.051Z",
RawAttributes: json.RawMessage(`{"foo":"bar"}`),
},
},
State: Active,
Expand Down