Skip to content
This repository was archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
feat: implement 'allowed_email_domains_list' group attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremad committed Nov 12, 2024
1 parent 8eaea58 commit 7d576d6
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
3 changes: 3 additions & 0 deletions groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ type Group struct {
MarkedForDeletionOn *ISOTime `json:"marked_for_deletion_on"`
CreatedAt *time.Time `json:"created_at"`
IPRestrictionRanges string `json:"ip_restriction_ranges"`
AllowedEmailDomainsList string `json:"allowed_email_domains_list"`
WikiAccessLevel AccessControlValue `json:"wiki_access_level"`

// Deprecated: Use EmailsEnabled instead
Expand Down Expand Up @@ -384,6 +385,7 @@ type CreateGroupOptions struct {
SharedRunnersMinutesLimit *int `url:"shared_runners_minutes_limit,omitempty" json:"shared_runners_minutes_limit,omitempty"`
ExtraSharedRunnersMinutesLimit *int `url:"extra_shared_runners_minutes_limit,omitempty" json:"extra_shared_runners_minutes_limit,omitempty"`
IPRestrictionRanges *string `url:"ip_restriction_ranges,omitempty" json:"ip_restriction_ranges,omitempty"`
AllowedEmailDomainsList *string `url:"allowed_email_domains_list,omitempty" json:"allowed_email_domains_list,omitempty"`
WikiAccessLevel *AccessControlValue `url:"wiki_access_level,omitempty" json:"wiki_access_level,omitempty"`

// Deprecated: Use EmailsEnabled instead
Expand Down Expand Up @@ -532,6 +534,7 @@ type UpdateGroupOptions struct {
SharedRunnersSetting *SharedRunnersSettingValue `url:"shared_runners_setting,omitempty" json:"shared_runners_setting,omitempty"`
PreventSharingGroupsOutsideHierarchy *bool `url:"prevent_sharing_groups_outside_hierarchy,omitempty" json:"prevent_sharing_groups_outside_hierarchy,omitempty"`
IPRestrictionRanges *string `url:"ip_restriction_ranges,omitempty" json:"ip_restriction_ranges,omitempty"`
AllowedEmailDomainsList *string `url:"allowed_email_domains_list,omitempty" json:"allowed_email_domains_list,omitempty"`
WikiAccessLevel *AccessControlValue `url:"wiki_access_level,omitempty" json:"wiki_access_level,omitempty"`

// Deprecated: Use EmailsEnabled instead
Expand Down
48 changes: 48 additions & 0 deletions groups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1124,3 +1124,51 @@ func TestEditGroupPushRules(t *testing.T) {
t.Errorf("Groups.EditGroupPushRule returned %+v, want %+v", rule, want)
}
}

func TestCreateGroupWithAllowedEmailDomainsList(t *testing.T) {
mux, client := setup(t)

mux.HandleFunc("/api/v4/groups",
func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodPost)
fmt.Fprint(w, `{"id": 1, "name": "g", "path": "g", "allowed_email_domains_list" : "example.com"}`)
})

opt := &CreateGroupOptions{
Name: Ptr("g"),
Path: Ptr("g"),
AllowedEmailDomainsList: Ptr("example.com"),
}

group, _, err := client.Groups.CreateGroup(opt, nil)
if err != nil {
t.Errorf("Groups.CreateGroup returned error: %v", err)
}

want := &Group{ID: 1, Name: "g", Path: "g", AllowedEmailDomainsList: "example.com"}
if !reflect.DeepEqual(want, group) {
t.Errorf("Groups.CreateGroup returned %+v, want %+v", group, want)
}
}

func TestUpdateGroupWithAllowedEmailDomainsList(t *testing.T) {
mux, client := setup(t)

mux.HandleFunc("/api/v4/groups/1",
func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodPut)
fmt.Fprint(w, `{"id": 1, "allowed_email_domains_list" : "example.com"}`)
})

group, _, err := client.Groups.UpdateGroup(1, &UpdateGroupOptions{
AllowedEmailDomainsList: Ptr("example.com"),
})
if err != nil {
t.Errorf("Groups.UpdateGroup returned error: %v", err)
}

want := &Group{ID: 1, AllowedEmailDomainsList: "example.com"}
if !reflect.DeepEqual(want, group) {
t.Errorf("Groups.UpdatedGroup returned %+v, want %+v", group, want)
}
}

0 comments on commit 7d576d6

Please sign in to comment.