2017-05-07 20:10:31 +05:30
|
|
|
// Copyright 2017 The Gitea Authors. All rights reserved.
|
2022-11-27 23:50:29 +05:30
|
|
|
// SPDX-License-Identifier: MIT
|
2017-05-07 20:10:31 +05:30
|
|
|
|
2022-09-03 00:48:23 +05:30
|
|
|
package integration
|
2017-05-07 20:10:31 +05:30
|
|
|
|
|
|
|
import (
|
2022-11-30 22:11:49 +05:30
|
|
|
"fmt"
|
2017-05-07 20:10:31 +05:30
|
|
|
"net/http"
|
2019-08-09 07:43:03 +05:30
|
|
|
"net/http/httptest"
|
2017-05-07 20:10:31 +05:30
|
|
|
"path"
|
2022-11-30 22:11:49 +05:30
|
|
|
"sync"
|
2017-05-07 20:10:31 +05:30
|
|
|
"testing"
|
|
|
|
|
2023-01-18 03:16:03 +05:30
|
|
|
auth_model "code.gitea.io/gitea/models/auth"
|
2021-07-24 21:33:58 +05:30
|
|
|
"code.gitea.io/gitea/modules/json"
|
2019-08-09 07:43:03 +05:30
|
|
|
"code.gitea.io/gitea/modules/setting"
|
2019-05-11 15:51:34 +05:30
|
|
|
api "code.gitea.io/gitea/modules/structs"
|
2022-09-03 00:48:23 +05:30
|
|
|
"code.gitea.io/gitea/tests"
|
2017-06-17 10:19:45 +05:30
|
|
|
|
2017-05-07 20:10:31 +05:30
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestRepoCommits(t *testing.T) {
|
2022-09-03 00:48:23 +05:30
|
|
|
defer tests.PrepareTestEnv(t)()
|
2017-05-07 20:10:31 +05:30
|
|
|
|
2017-06-17 10:19:45 +05:30
|
|
|
session := loginUser(t, "user2")
|
2017-05-07 20:10:31 +05:30
|
|
|
|
|
|
|
// Request repository commits page
|
2017-10-30 07:34:25 +05:30
|
|
|
req := NewRequest(t, "GET", "/user2/repo1/commits/branch/master")
|
2017-07-08 01:06:47 +05:30
|
|
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
2017-05-07 20:10:31 +05:30
|
|
|
|
2017-06-17 21:59:59 +05:30
|
|
|
doc := NewHTMLParser(t, resp.Body)
|
2017-05-07 20:10:31 +05:30
|
|
|
commitURL, exists := doc.doc.Find("#commits-table tbody tr td.sha a").Attr("href")
|
|
|
|
assert.True(t, exists)
|
|
|
|
assert.NotEmpty(t, commitURL)
|
|
|
|
}
|
|
|
|
|
|
|
|
func doTestRepoCommitWithStatus(t *testing.T, state string, classes ...string) {
|
2022-09-03 00:48:23 +05:30
|
|
|
defer tests.PrepareTestEnv(t)()
|
2017-05-07 20:10:31 +05:30
|
|
|
|
2017-06-17 10:19:45 +05:30
|
|
|
session := loginUser(t, "user2")
|
2017-05-07 20:10:31 +05:30
|
|
|
|
|
|
|
// Request repository commits page
|
2017-10-30 07:34:25 +05:30
|
|
|
req := NewRequest(t, "GET", "/user2/repo1/commits/branch/master")
|
2017-07-08 01:06:47 +05:30
|
|
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
2017-05-07 20:10:31 +05:30
|
|
|
|
2017-06-17 21:59:59 +05:30
|
|
|
doc := NewHTMLParser(t, resp.Body)
|
2017-05-07 20:10:31 +05:30
|
|
|
// Get first commit URL
|
|
|
|
commitURL, exists := doc.doc.Find("#commits-table tbody tr td.sha a").Attr("href")
|
|
|
|
assert.True(t, exists)
|
|
|
|
assert.NotEmpty(t, commitURL)
|
|
|
|
|
|
|
|
// Call API to add status for commit
|
Redesign Scoped Access Tokens (#24767)
## Changes
- Adds the following high level access scopes, each with `read` and
`write` levels:
- `activitypub`
- `admin` (hidden if user is not a site admin)
- `misc`
- `notification`
- `organization`
- `package`
- `issue`
- `repository`
- `user`
- Adds new middleware function `tokenRequiresScopes()` in addition to
`reqToken()`
- `tokenRequiresScopes()` is used for each high-level api section
- _if_ a scoped token is present, checks that the required scope is
included based on the section and HTTP method
- `reqToken()` is used for individual routes
- checks that required authentication is present (but does not check
scope levels as this will already have been handled by
`tokenRequiresScopes()`
- Adds migration to convert old scoped access tokens to the new set of
scopes
- Updates the user interface for scope selection
### User interface example
<img width="903" alt="Screen Shot 2023-05-31 at 1 56 55 PM"
src="https://github.com/go-gitea/gitea/assets/23248839/654766ec-2143-4f59-9037-3b51600e32f3">
<img width="917" alt="Screen Shot 2023-05-31 at 1 56 43 PM"
src="https://github.com/go-gitea/gitea/assets/23248839/1ad64081-012c-4a73-b393-66b30352654c">
## tokenRequiresScopes Design Decision
- `tokenRequiresScopes()` was added to more reliably cover api routes.
For an incoming request, this function uses the given scope category
(say `AccessTokenScopeCategoryOrganization`) and the HTTP method (say
`DELETE`) and verifies that any scoped tokens in use include
`delete:organization`.
- `reqToken()` is used to enforce auth for individual routes that
require it. If a scoped token is not present for a request,
`tokenRequiresScopes()` will not return an error
## TODO
- [x] Alphabetize scope categories
- [x] Change 'public repos only' to a radio button (private vs public).
Also expand this to organizations
- [X] Disable token creation if no scopes selected. Alternatively, show
warning
- [x] `reqToken()` is missing from many `POST/DELETE` routes in the api.
`tokenRequiresScopes()` only checks that a given token has the correct
scope, `reqToken()` must be used to check that a token (or some other
auth) is present.
- _This should be addressed in this PR_
- [x] The migration should be reviewed very carefully in order to
minimize access changes to existing user tokens.
- _This should be addressed in this PR_
- [x] Link to api to swagger documentation, clarify what
read/write/delete levels correspond to
- [x] Review cases where more than one scope is needed as this directly
deviates from the api definition.
- _This should be addressed in this PR_
- For example:
```go
m.Group("/users/{username}/orgs", func() {
m.Get("", reqToken(), org.ListUserOrgs)
m.Get("/{org}/permissions", reqToken(), org.GetUserOrgsPermissions)
}, tokenRequiresScopes(auth_model.AccessTokenScopeCategoryUser,
auth_model.AccessTokenScopeCategoryOrganization),
context_service.UserAssignmentAPI())
```
## Future improvements
- [ ] Add required scopes to swagger documentation
- [ ] Redesign `reqToken()` to be opt-out rather than opt-in
- [ ] Subdivide scopes like `repository`
- [ ] Once a token is created, if it has no scopes, we should display
text instead of an empty bullet point
- [ ] If the 'public repos only' option is selected, should read
categories be selected by default
Closes #24501
Closes #24799
Co-authored-by: Jonathan Tran <jon@allspice.io>
Co-authored-by: Kyle D <kdumontnu@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
2023-06-05 00:27:16 +05:30
|
|
|
ctx := NewAPITestContext(t, "user2", "repo1", auth_model.AccessTokenScopeWriteRepository)
|
2023-02-20 14:13:04 +05:30
|
|
|
t.Run("CreateStatus", doAPICreateCommitStatus(ctx, path.Base(commitURL), api.CreateStatusOption{
|
|
|
|
State: api.CommitStatusState(state),
|
|
|
|
TargetURL: "http://test.ci/",
|
|
|
|
Description: "",
|
|
|
|
Context: "testci",
|
|
|
|
}))
|
2017-05-07 20:10:31 +05:30
|
|
|
|
2017-10-30 07:34:25 +05:30
|
|
|
req = NewRequest(t, "GET", "/user2/repo1/commits/branch/master")
|
2017-07-08 01:06:47 +05:30
|
|
|
resp = session.MakeRequest(t, req, http.StatusOK)
|
2017-05-07 20:10:31 +05:30
|
|
|
|
2017-06-17 21:59:59 +05:30
|
|
|
doc = NewHTMLParser(t, resp.Body)
|
2023-02-20 14:13:04 +05:30
|
|
|
// Check if commit status is displayed in message column (.tippy-target to ignore the tippy trigger)
|
|
|
|
sel := doc.doc.Find("#commits-table tbody tr td.message .tippy-target .commit-status")
|
2021-06-07 10:57:09 +05:30
|
|
|
assert.Equal(t, 1, sel.Length())
|
2017-05-07 20:10:31 +05:30
|
|
|
for _, class := range classes {
|
|
|
|
assert.True(t, sel.HasClass(class))
|
|
|
|
}
|
2019-08-09 07:43:03 +05:30
|
|
|
|
2022-01-20 23:16:10 +05:30
|
|
|
// By SHA
|
2019-08-09 07:43:03 +05:30
|
|
|
req = NewRequest(t, "GET", "/api/v1/repos/user2/repo1/commits/"+path.Base(commitURL)+"/statuses")
|
2021-07-13 12:44:14 +05:30
|
|
|
reqOne := NewRequest(t, "GET", "/api/v1/repos/user2/repo1/commits/"+path.Base(commitURL)+"/status")
|
|
|
|
testRepoCommitsWithStatus(t, session.MakeRequest(t, req, http.StatusOK), session.MakeRequest(t, reqOne, http.StatusOK), state)
|
2022-12-27 18:42:49 +05:30
|
|
|
|
|
|
|
// By short SHA
|
|
|
|
req = NewRequest(t, "GET", "/api/v1/repos/user2/repo1/commits/"+path.Base(commitURL)[:10]+"/statuses")
|
|
|
|
reqOne = NewRequest(t, "GET", "/api/v1/repos/user2/repo1/commits/"+path.Base(commitURL)[:10]+"/status")
|
|
|
|
testRepoCommitsWithStatus(t, session.MakeRequest(t, req, http.StatusOK), session.MakeRequest(t, reqOne, http.StatusOK), state)
|
2021-07-13 12:44:14 +05:30
|
|
|
|
2022-01-20 23:16:10 +05:30
|
|
|
// By Ref
|
2019-08-09 07:43:03 +05:30
|
|
|
req = NewRequest(t, "GET", "/api/v1/repos/user2/repo1/commits/master/statuses")
|
2021-07-13 12:44:14 +05:30
|
|
|
reqOne = NewRequest(t, "GET", "/api/v1/repos/user2/repo1/commits/master/status")
|
|
|
|
testRepoCommitsWithStatus(t, session.MakeRequest(t, req, http.StatusOK), session.MakeRequest(t, reqOne, http.StatusOK), state)
|
2019-08-09 07:43:03 +05:30
|
|
|
req = NewRequest(t, "GET", "/api/v1/repos/user2/repo1/commits/v1.1/statuses")
|
2021-07-13 12:44:14 +05:30
|
|
|
reqOne = NewRequest(t, "GET", "/api/v1/repos/user2/repo1/commits/v1.1/status")
|
|
|
|
testRepoCommitsWithStatus(t, session.MakeRequest(t, req, http.StatusOK), session.MakeRequest(t, reqOne, http.StatusOK), state)
|
2019-08-09 07:43:03 +05:30
|
|
|
}
|
|
|
|
|
2021-07-13 12:44:14 +05:30
|
|
|
func testRepoCommitsWithStatus(t *testing.T, resp, respOne *httptest.ResponseRecorder, state string) {
|
|
|
|
var statuses []*api.CommitStatus
|
|
|
|
assert.NoError(t, json.Unmarshal(resp.Body.Bytes(), &statuses))
|
|
|
|
var status api.CombinedStatus
|
|
|
|
assert.NoError(t, json.Unmarshal(respOne.Body.Bytes(), &status))
|
|
|
|
assert.NotNil(t, status)
|
|
|
|
|
|
|
|
if assert.Len(t, statuses, 1) {
|
|
|
|
assert.Equal(t, api.CommitStatusState(state), statuses[0].State)
|
|
|
|
assert.Equal(t, setting.AppURL+"api/v1/repos/user2/repo1/statuses/65f1bf27bc3bf70f64657658635e66094edbcb4d", statuses[0].URL)
|
|
|
|
assert.Equal(t, "http://test.ci/", statuses[0].TargetURL)
|
|
|
|
assert.Equal(t, "", statuses[0].Description)
|
|
|
|
assert.Equal(t, "testci", statuses[0].Context)
|
|
|
|
|
|
|
|
assert.Len(t, status.Statuses, 1)
|
|
|
|
assert.Equal(t, statuses[0], status.Statuses[0])
|
|
|
|
assert.Equal(t, "65f1bf27bc3bf70f64657658635e66094edbcb4d", status.SHA)
|
2019-08-09 07:43:03 +05:30
|
|
|
}
|
2017-05-07 20:10:31 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
func TestRepoCommitsWithStatusPending(t *testing.T) {
|
2023-07-18 22:29:02 +05:30
|
|
|
doTestRepoCommitWithStatus(t, "pending", "octicon-dot-fill", "yellow")
|
2017-05-07 20:10:31 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
func TestRepoCommitsWithStatusSuccess(t *testing.T) {
|
2022-08-10 03:25:29 +05:30
|
|
|
doTestRepoCommitWithStatus(t, "success", "octicon-check", "green")
|
2017-05-07 20:10:31 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
func TestRepoCommitsWithStatusError(t *testing.T) {
|
2022-08-10 03:25:29 +05:30
|
|
|
doTestRepoCommitWithStatus(t, "error", "gitea-exclamation", "red")
|
2017-05-07 20:10:31 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
func TestRepoCommitsWithStatusFailure(t *testing.T) {
|
2022-08-10 03:25:29 +05:30
|
|
|
doTestRepoCommitWithStatus(t, "failure", "octicon-x", "red")
|
2017-05-07 20:10:31 +05:30
|
|
|
}
|
|
|
|
|
2022-11-30 22:11:49 +05:30
|
|
|
func TestRepoCommitsStatusParallel(t *testing.T) {
|
|
|
|
defer tests.PrepareTestEnv(t)()
|
|
|
|
|
|
|
|
session := loginUser(t, "user2")
|
|
|
|
|
|
|
|
// Request repository commits page
|
|
|
|
req := NewRequest(t, "GET", "/user2/repo1/commits/branch/master")
|
|
|
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
|
|
|
|
|
|
|
doc := NewHTMLParser(t, resp.Body)
|
|
|
|
// Get first commit URL
|
|
|
|
commitURL, exists := doc.doc.Find("#commits-table tbody tr td.sha a").Attr("href")
|
|
|
|
assert.True(t, exists)
|
|
|
|
assert.NotEmpty(t, commitURL)
|
|
|
|
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
for i := 0; i < 10; i++ {
|
|
|
|
wg.Add(1)
|
2022-12-02 08:45:36 +05:30
|
|
|
go func(parentT *testing.T, i int) {
|
|
|
|
parentT.Run(fmt.Sprintf("ParallelCreateStatus_%d", i), func(t *testing.T) {
|
Redesign Scoped Access Tokens (#24767)
## Changes
- Adds the following high level access scopes, each with `read` and
`write` levels:
- `activitypub`
- `admin` (hidden if user is not a site admin)
- `misc`
- `notification`
- `organization`
- `package`
- `issue`
- `repository`
- `user`
- Adds new middleware function `tokenRequiresScopes()` in addition to
`reqToken()`
- `tokenRequiresScopes()` is used for each high-level api section
- _if_ a scoped token is present, checks that the required scope is
included based on the section and HTTP method
- `reqToken()` is used for individual routes
- checks that required authentication is present (but does not check
scope levels as this will already have been handled by
`tokenRequiresScopes()`
- Adds migration to convert old scoped access tokens to the new set of
scopes
- Updates the user interface for scope selection
### User interface example
<img width="903" alt="Screen Shot 2023-05-31 at 1 56 55 PM"
src="https://github.com/go-gitea/gitea/assets/23248839/654766ec-2143-4f59-9037-3b51600e32f3">
<img width="917" alt="Screen Shot 2023-05-31 at 1 56 43 PM"
src="https://github.com/go-gitea/gitea/assets/23248839/1ad64081-012c-4a73-b393-66b30352654c">
## tokenRequiresScopes Design Decision
- `tokenRequiresScopes()` was added to more reliably cover api routes.
For an incoming request, this function uses the given scope category
(say `AccessTokenScopeCategoryOrganization`) and the HTTP method (say
`DELETE`) and verifies that any scoped tokens in use include
`delete:organization`.
- `reqToken()` is used to enforce auth for individual routes that
require it. If a scoped token is not present for a request,
`tokenRequiresScopes()` will not return an error
## TODO
- [x] Alphabetize scope categories
- [x] Change 'public repos only' to a radio button (private vs public).
Also expand this to organizations
- [X] Disable token creation if no scopes selected. Alternatively, show
warning
- [x] `reqToken()` is missing from many `POST/DELETE` routes in the api.
`tokenRequiresScopes()` only checks that a given token has the correct
scope, `reqToken()` must be used to check that a token (or some other
auth) is present.
- _This should be addressed in this PR_
- [x] The migration should be reviewed very carefully in order to
minimize access changes to existing user tokens.
- _This should be addressed in this PR_
- [x] Link to api to swagger documentation, clarify what
read/write/delete levels correspond to
- [x] Review cases where more than one scope is needed as this directly
deviates from the api definition.
- _This should be addressed in this PR_
- For example:
```go
m.Group("/users/{username}/orgs", func() {
m.Get("", reqToken(), org.ListUserOrgs)
m.Get("/{org}/permissions", reqToken(), org.GetUserOrgsPermissions)
}, tokenRequiresScopes(auth_model.AccessTokenScopeCategoryUser,
auth_model.AccessTokenScopeCategoryOrganization),
context_service.UserAssignmentAPI())
```
## Future improvements
- [ ] Add required scopes to swagger documentation
- [ ] Redesign `reqToken()` to be opt-out rather than opt-in
- [ ] Subdivide scopes like `repository`
- [ ] Once a token is created, if it has no scopes, we should display
text instead of an empty bullet point
- [ ] If the 'public repos only' option is selected, should read
categories be selected by default
Closes #24501
Closes #24799
Co-authored-by: Jonathan Tran <jon@allspice.io>
Co-authored-by: Kyle D <kdumontnu@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
2023-06-05 00:27:16 +05:30
|
|
|
ctx := NewAPITestContext(t, "user2", "repo1", auth_model.AccessTokenScopeWriteRepository)
|
2023-02-20 14:13:04 +05:30
|
|
|
runBody := doAPICreateCommitStatus(ctx, path.Base(commitURL), api.CreateStatusOption{
|
|
|
|
State: api.CommitStatusPending,
|
|
|
|
TargetURL: "http://test.ci/",
|
|
|
|
Description: "",
|
|
|
|
Context: "testci",
|
|
|
|
})
|
2022-11-30 22:11:49 +05:30
|
|
|
runBody(t)
|
|
|
|
wg.Done()
|
|
|
|
})
|
|
|
|
}(t, i)
|
|
|
|
}
|
|
|
|
wg.Wait()
|
|
|
|
}
|
2023-02-20 14:13:04 +05:30
|
|
|
|
|
|
|
func TestRepoCommitsStatusMultiple(t *testing.T) {
|
|
|
|
defer tests.PrepareTestEnv(t)()
|
|
|
|
|
|
|
|
session := loginUser(t, "user2")
|
|
|
|
|
|
|
|
// Request repository commits page
|
|
|
|
req := NewRequest(t, "GET", "/user2/repo1/commits/branch/master")
|
|
|
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
|
|
|
|
|
|
|
doc := NewHTMLParser(t, resp.Body)
|
|
|
|
// Get first commit URL
|
|
|
|
commitURL, exists := doc.doc.Find("#commits-table tbody tr td.sha a").Attr("href")
|
|
|
|
assert.True(t, exists)
|
|
|
|
assert.NotEmpty(t, commitURL)
|
|
|
|
|
|
|
|
// Call API to add status for commit
|
Redesign Scoped Access Tokens (#24767)
## Changes
- Adds the following high level access scopes, each with `read` and
`write` levels:
- `activitypub`
- `admin` (hidden if user is not a site admin)
- `misc`
- `notification`
- `organization`
- `package`
- `issue`
- `repository`
- `user`
- Adds new middleware function `tokenRequiresScopes()` in addition to
`reqToken()`
- `tokenRequiresScopes()` is used for each high-level api section
- _if_ a scoped token is present, checks that the required scope is
included based on the section and HTTP method
- `reqToken()` is used for individual routes
- checks that required authentication is present (but does not check
scope levels as this will already have been handled by
`tokenRequiresScopes()`
- Adds migration to convert old scoped access tokens to the new set of
scopes
- Updates the user interface for scope selection
### User interface example
<img width="903" alt="Screen Shot 2023-05-31 at 1 56 55 PM"
src="https://github.com/go-gitea/gitea/assets/23248839/654766ec-2143-4f59-9037-3b51600e32f3">
<img width="917" alt="Screen Shot 2023-05-31 at 1 56 43 PM"
src="https://github.com/go-gitea/gitea/assets/23248839/1ad64081-012c-4a73-b393-66b30352654c">
## tokenRequiresScopes Design Decision
- `tokenRequiresScopes()` was added to more reliably cover api routes.
For an incoming request, this function uses the given scope category
(say `AccessTokenScopeCategoryOrganization`) and the HTTP method (say
`DELETE`) and verifies that any scoped tokens in use include
`delete:organization`.
- `reqToken()` is used to enforce auth for individual routes that
require it. If a scoped token is not present for a request,
`tokenRequiresScopes()` will not return an error
## TODO
- [x] Alphabetize scope categories
- [x] Change 'public repos only' to a radio button (private vs public).
Also expand this to organizations
- [X] Disable token creation if no scopes selected. Alternatively, show
warning
- [x] `reqToken()` is missing from many `POST/DELETE` routes in the api.
`tokenRequiresScopes()` only checks that a given token has the correct
scope, `reqToken()` must be used to check that a token (or some other
auth) is present.
- _This should be addressed in this PR_
- [x] The migration should be reviewed very carefully in order to
minimize access changes to existing user tokens.
- _This should be addressed in this PR_
- [x] Link to api to swagger documentation, clarify what
read/write/delete levels correspond to
- [x] Review cases where more than one scope is needed as this directly
deviates from the api definition.
- _This should be addressed in this PR_
- For example:
```go
m.Group("/users/{username}/orgs", func() {
m.Get("", reqToken(), org.ListUserOrgs)
m.Get("/{org}/permissions", reqToken(), org.GetUserOrgsPermissions)
}, tokenRequiresScopes(auth_model.AccessTokenScopeCategoryUser,
auth_model.AccessTokenScopeCategoryOrganization),
context_service.UserAssignmentAPI())
```
## Future improvements
- [ ] Add required scopes to swagger documentation
- [ ] Redesign `reqToken()` to be opt-out rather than opt-in
- [ ] Subdivide scopes like `repository`
- [ ] Once a token is created, if it has no scopes, we should display
text instead of an empty bullet point
- [ ] If the 'public repos only' option is selected, should read
categories be selected by default
Closes #24501
Closes #24799
Co-authored-by: Jonathan Tran <jon@allspice.io>
Co-authored-by: Kyle D <kdumontnu@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
2023-06-05 00:27:16 +05:30
|
|
|
ctx := NewAPITestContext(t, "user2", "repo1", auth_model.AccessTokenScopeWriteRepository)
|
2023-02-20 14:13:04 +05:30
|
|
|
t.Run("CreateStatus", doAPICreateCommitStatus(ctx, path.Base(commitURL), api.CreateStatusOption{
|
|
|
|
State: api.CommitStatusSuccess,
|
|
|
|
TargetURL: "http://test.ci/",
|
|
|
|
Description: "",
|
|
|
|
Context: "testci",
|
|
|
|
}))
|
|
|
|
|
|
|
|
t.Run("CreateStatus", doAPICreateCommitStatus(ctx, path.Base(commitURL), api.CreateStatusOption{
|
|
|
|
State: api.CommitStatusSuccess,
|
|
|
|
TargetURL: "http://test.ci/",
|
|
|
|
Description: "",
|
|
|
|
Context: "other_context",
|
|
|
|
}))
|
|
|
|
|
|
|
|
req = NewRequest(t, "GET", "/user2/repo1/commits/branch/master")
|
|
|
|
resp = session.MakeRequest(t, req, http.StatusOK)
|
|
|
|
|
|
|
|
doc = NewHTMLParser(t, resp.Body)
|
|
|
|
// Check that the data-tippy="commit-statuses" (for trigger) and commit-status (svg) are present
|
|
|
|
sel := doc.doc.Find("#commits-table tbody tr td.message [data-tippy=\"commit-statuses\"] .commit-status")
|
|
|
|
assert.Equal(t, 1, sel.Length())
|
|
|
|
}
|