Skip to content

Commit

Permalink
Fix SAML Group Links Access Level type
Browse files Browse the repository at this point in the history
While working on gitlabhq/terraform-provider-gitlab#1215
I have noticed that the access level type introcued in
#1527
is wrong.
  • Loading branch information
timofurrer committed Aug 23, 2022
1 parent 88c4146 commit c6383e6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ type LDAPGroupLink struct {
//
// GitLab API docs: https://docs.gitlab.com/ce/api/groups.html#saml-group-links
type SAMLGroupLink struct {
Name string `json:"name"`
AccessLevel string `json:"access_level"`
Name string `json:"name"`
AccessLevel AccessLevelValue `json:"access_level"`
}

// ListGroupsOptions represents the available ListGroups() options.
Expand Down Expand Up @@ -810,8 +810,8 @@ func (s *GroupsService) GetGroupSAMLLink(gid interface{}, samlGroupName string,
// GitLab API docs:
// https://docs.gitlab.com/ee/api/groups.html#add-saml-group-link
type AddGroupSAMLLinkOptions struct {
SAMLGroupName *string `url:"saml_group_name,omitempty" json:"saml_group_name,omitempty"`
AccessLevel *string `url:"access_level,omitempty" json:"access_level,omitempty"`
SAMLGroupName *string `url:"saml_group_name,omitempty" json:"saml_group_name,omitempty"`
AccessLevel *AccessLevelValue `url:"access_level,omitempty" json:"access_level,omitempty"`
}

// AddGroupSAMLLink creates a new group SAML link. Available only for users who
Expand Down
18 changes: 9 additions & 9 deletions groups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,11 +373,11 @@ func TestListGroupSAMLLinks(t *testing.T) {
testMethod(t, r, http.MethodGet)
fmt.Fprint(w, `[
{
"access_level":"Developer",
"access_level":30,
"name":"gitlab_group_example_developer"
},
{
"access_level":"Maintainer",
"access_level":40,
"name":"gitlab_group_example_maintainer"
}
]`)
Expand All @@ -390,11 +390,11 @@ func TestListGroupSAMLLinks(t *testing.T) {

want := []*SAMLGroupLink{
{
AccessLevel: "Developer",
AccessLevel: DeveloperPermissions,
Name: "gitlab_group_example_developer",
},
{
AccessLevel: "Maintainer",
AccessLevel: MaintainerPermissions,
Name: "gitlab_group_example_maintainer",
},
}
Expand All @@ -412,7 +412,7 @@ func TestGetGroupSAMLLink(t *testing.T) {
testMethod(t, r, http.MethodGet)
fmt.Fprint(w, `
{
"access_level":"Developer",
"access_level":30,
"name":"gitlab_group_example_developer"
}`)
})
Expand All @@ -423,7 +423,7 @@ func TestGetGroupSAMLLink(t *testing.T) {
}

want := &SAMLGroupLink{
AccessLevel: "Developer",
AccessLevel: DeveloperPermissions,
Name: "gitlab_group_example_developer",
}
if !reflect.DeepEqual(want, links) {
Expand All @@ -440,14 +440,14 @@ func TestAddGroupSAMLLink(t *testing.T) {
testMethod(t, r, http.MethodPost)
fmt.Fprint(w, `
{
"access_level":"Developer",
"access_level":30,
"name":"gitlab_group_example_developer"
}`)
})

opt := &AddGroupSAMLLinkOptions{
SAMLGroupName: String("gitlab_group_example_developer"),
AccessLevel: String("Developer"),
AccessLevel: AccessLevel(DeveloperPermissions),
}

link, _, err := client.Groups.AddGroupSAMLLink(1, opt)
Expand All @@ -456,7 +456,7 @@ func TestAddGroupSAMLLink(t *testing.T) {
}

want := &SAMLGroupLink{
AccessLevel: "Developer",
AccessLevel: DeveloperPermissions,
Name: "gitlab_group_example_developer",
}
if !reflect.DeepEqual(want, link) {
Expand Down

0 comments on commit c6383e6

Please sign in to comment.