-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Fixes #7023 - API Org Visibility #7028
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
Merged
techknowlogick
merged 16 commits into
go-gitea:master
from
richmahn:fix-7023-api-org-visibility
May 30, 2019
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
76a7001
Fixes #7023 - API Org Visibility
richmahn 134ee6b
Fixes swagger and formatting
richmahn 5ef5d8b
Changes per review
richmahn 145ac2b
Func name change due to review
richmahn bd1cd7f
Add visibility enum
zeripath 4a5cb73
Fix to binding
richmahn bcc1d6a
Moves documentation from swagger header to schema struct for Org crea…
richmahn 55d16f1
Adds required property to the content field of create and update repo…
richmahn 5f7a8c9
Update the message comment
richmahn 901f639
Uses back ticks to better show fields and values for swagger
richmahn 7e33e61
Fmt fix
richmahn 4713c24
Merge remote-tracking branch 'upstream/master' into fix-7023-api-org-…
richmahn 8805b33
Merge remote-tracking branch 'upstream/master' into fix-7023-api-org-…
richmahn 9abf44e
Merge remote-tracking branch 'upstream/master' into fix-7023-api-org-…
richmahn 5256cb4
Merge branch 'master' into fix-7023-api-org-visibility
lafriks 7098cd5
Merge branch 'master' into fix-7023-api-org-visibility
techknowlogick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// Copyright 2019 The Gitea Authors. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package integrations | ||
|
||
import ( | ||
"net/http" | ||
"net/url" | ||
"strings" | ||
"testing" | ||
|
||
"code.gitea.io/gitea/models" | ||
api "code.gitea.io/gitea/modules/structs" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestAPIAdminOrgCreate(t *testing.T) { | ||
onGiteaRun(t, func(*testing.T, *url.URL) { | ||
session := loginUser(t, "user1") | ||
token := getTokenForLoggedInUser(t, session) | ||
|
||
var org = api.CreateOrgOption{ | ||
UserName: "user2_org", | ||
FullName: "User2's organization", | ||
Description: "This organization created by admin for user2", | ||
Website: "https://try.gitea.io", | ||
Location: "Shanghai", | ||
Visibility: "private", | ||
} | ||
req := NewRequestWithJSON(t, "POST", "/api/v1/admin/users/user2/orgs?token="+token, &org) | ||
resp := session.MakeRequest(t, req, http.StatusCreated) | ||
|
||
var apiOrg api.Organization | ||
DecodeJSON(t, resp, &apiOrg) | ||
|
||
assert.Equal(t, org.UserName, apiOrg.UserName) | ||
assert.Equal(t, org.FullName, apiOrg.FullName) | ||
assert.Equal(t, org.Description, apiOrg.Description) | ||
assert.Equal(t, org.Website, apiOrg.Website) | ||
assert.Equal(t, org.Location, apiOrg.Location) | ||
assert.Equal(t, org.Visibility, apiOrg.Visibility) | ||
|
||
models.AssertExistsAndLoadBean(t, &models.User{ | ||
Name: org.UserName, | ||
LowerName: strings.ToLower(org.UserName), | ||
FullName: org.FullName, | ||
}) | ||
}) | ||
} | ||
|
||
func TestAPIAdminOrgCreateBadVisibility(t *testing.T) { | ||
onGiteaRun(t, func(*testing.T, *url.URL) { | ||
session := loginUser(t, "user1") | ||
token := getTokenForLoggedInUser(t, session) | ||
|
||
var org = api.CreateOrgOption{ | ||
UserName: "user2_org", | ||
FullName: "User2's organization", | ||
Description: "This organization created by admin for user2", | ||
Website: "https://try.gitea.io", | ||
Location: "Shanghai", | ||
Visibility: "notvalid", | ||
} | ||
req := NewRequestWithJSON(t, "POST", "/api/v1/admin/users/user2/orgs?token="+token, &org) | ||
session.MakeRequest(t, req, http.StatusUnprocessableEntity) | ||
}) | ||
} | ||
|
||
func TestAPIAdminOrgCreateNotAdmin(t *testing.T) { | ||
prepareTestEnv(t) | ||
nonAdminUsername := "user2" | ||
session := loginUser(t, nonAdminUsername) | ||
token := getTokenForLoggedInUser(t, session) | ||
var org = api.CreateOrgOption{ | ||
UserName: "user2_org", | ||
FullName: "User2's organization", | ||
Description: "This organization created by admin for user2", | ||
Website: "https://try.gitea.io", | ||
Location: "Shanghai", | ||
Visibility: "public", | ||
} | ||
req := NewRequestWithJSON(t, "POST", "/api/v1/admin/users/user2/orgs?token="+token, &org) | ||
session.MakeRequest(t, req, http.StatusForbidden) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.