Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SAML Group Links Access Level type #1531

Merged
merged 1 commit into from Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions groups.go
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
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