summaryrefslogtreecommitdiffstats
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* add skip ci functionality (#28075)Denys Konovalov2023-11-181-0/+91
| | | | | | | | | | | | Adds the possibility to skip workflow execution if the commit message contains a string like [skip ci] or similar. The default strings are the same as on GitHub, users can also set custom ones in app.ini Reference: https://docs.github.com/en/actions/managing-workflow-runs/skipping-workflow-runs Close #28020
* Enable system users search via the API (#28013)Earl Warren2023-11-131-0/+22
| | | | | Refs: https://codeberg.org/forgejo/forgejo/issues/1403 (cherry picked from commit dd4d17c159eaf8b642aa9e6105b0532e25972bb7)
* Enable system users for comment.LoadPoster (#28014)Earl Warren2023-11-131-0/+37
| | | | | | | | | | | | System users (Ghost, ActionsUser, etc) have a negative id and may be the author of a comment, either because it was created by a now deleted user or via an action using a transient token. The GetPossibleUserByID function has special cases related to system users and will not fail if given a negative id. Refs: https://codeberg.org/forgejo/forgejo/issues/1425 (cherry picked from commit 6a2d2fa24390116d31ae2507c0a93d423f690b7b)
* Unify two factor check (#27915)KN4CK3R2023-11-061-0/+55
| | | | | | | | Fixes #27819 We have support for two factor logins with the normal web login and with basic auth. For basic auth the two factor check was implemented at three different places and you need to know that this check is necessary. This PR moves the check into the basic auth itself.
* Add user secrets API integration tests (#27832)Jean-Baptiste Gomond2023-10-311-0/+98
| | | | Adds the missing user secrets API integration tests so #27829 does not happen again
* List all Debian package versions in `Packages` (#27786)KN4CK3R2023-10-291-18/+28
| | | | | | Closes #27783 This PR lists all and not only the latest package versions in the `Packages` index.
* Upgrade to golangci-lint@v1.55.0 (#27756)silverwind2023-10-241-2/+1
| | | https://github.com/golangci/golangci-lint/releases/tag/v1.55.0
* Remove unnecessary parameter (#27671)Lunny Xiao2023-10-181-1/+1
|
* Improve retrying index issues (#27554)Jason Song2023-10-151-1/+2
| | | Fix #27540
* Replace more db.DefaultContext (#27628)Lunny Xiao2023-10-151-1/+1
| | | Target #27065
* Final round of `db.DefaultContext` refactor (#27587)JakobDev2023-10-142-11/+11
| | | Last part of #27065
* Fix permissions for Token DELETE endpoint to match GET and POST (#27610)Evan Tobin2023-10-141-2/+29
| | | | | | | | Fixes #27598 In #27080, the logic for the tokens endpoints were updated to allow admins to create and view tokens in other accounts. However, the same functionality was not added to the DELETE endpoint. This PR makes the DELETE endpoint function the same as the other token endpoints and adds unit tests
* Enhanced auth token / remember me (#27606)KN4CK3R2023-10-141-0/+36
| | | | | | | | | | | | | | | | | Closes #27455 > The mechanism responsible for long-term authentication (the 'remember me' cookie) uses a weak construction technique. It will hash the user's hashed password and the rands value; it will then call the secure cookie code, which will encrypt the user's name with the computed hash. If one were able to dump the database, they could extract those two values to rebuild that cookie and impersonate a user. That vulnerability exists from the date the dump was obtained until a user changed their password. > > To fix this security issue, the cookie could be created and verified using a different technique such as the one explained at https://paragonie.com/blog/2015/04/secure-authentication-php-with-long-term-persistence#secure-remember-me-cookies. The PR removes the now obsolete setting `COOKIE_USERNAME`.
* Replace assert.Fail with assert.FailNow (#27578)Nanguan Lin2023-10-116-15/+5
| | | | | | | | | assert.Fail() will continue to execute the code while assert.FailNow() not. I thought those uses of assert.Fail() should exit immediately. PS: perhaps it's a good idea to use [require](https://pkg.go.dev/github.com/stretchr/testify/require) somewhere because the assert package's default behavior does not exit when an error occurs, which makes it difficult to find the root error reason.
* show manual cron run's last time (#27544)Earl Warren2023-10-111-0/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | - Currently in the cron tasks, the 'Previous Time' only displays the previous time of when the cron library executes the function, but not any of the manual executions of the task. - Store the last run's time in memory in the Task struct and use that, when that time is later than time that the cron library has executed this task. - This ensures that if an instance admin manually starts a task, there's feedback that this task is/has been run, because the task might be run that quick, that the status icon already has been changed to an checkmark, - Tasks that are executed at startup now reflect this as well, as the time of the execution of that task on startup is now being shown as 'Previous Time'. - Added integration tests for the API part, which is easier to test because querying the HTML table of cron tasks is non-trivial. - Resolves https://codeberg.org/forgejo/forgejo/issues/949 (cherry picked from commit fd34fdac1408ece6b7d9fe6a76501ed9a45d06fa) --------- Co-authored-by: Gusted <postmaster@gusted.xyz> Co-authored-by: KN4CK3R <admin@oldschoolhack.me> Co-authored-by: silverwind <me@silverwind.io>
* Penultimate round of `db.DefaultContext` refactor (#27414)JakobDev2023-10-112-2/+2
| | | | | | | Part of #27065 --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Fix the wrong HTTP response status code for duplicate packages (#27480)Nanguan Lin2023-10-108-10/+10
| | | | | | | | fix #27470 (hope there is nothing missing 😢 ) --------- Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* api: GetPullRequestCommits: return file list (#27483)Michael Santos2023-10-092-0/+7
| | | | | | | | Fixes https://github.com/go-gitea/gitea/issues/27481 ---- Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Restore warning commit status (#27504)silverwind2023-10-082-0/+6
| | | | | | | | | | | | | Partial revert of https://github.com/go-gitea/gitea/pull/25839. This commit status is used by a number of external integrations, so I think we should not remove it (See https://github.com/go-gitea/gitea/pull/25839#issuecomment-1729002077). This is a rare case where an existing migration needed to be alterted to avoid data loss. --------- Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: Giteabot <teabot@gitea.io>
* Require MySQL 8.0, PostgreSQL 12, MSSQL 2012 (#27337)silverwind2023-10-034-115/+4
| | | | | | | | | | | | | | | | | | | | | | | - MySQL 5.7 support and testing is dropped - MySQL tests now execute against 8.1, up from 5.7 and 8.0 - PostgreSQL 10 and 11 support ist dropped - PostgreSQL tests now execute against 16, up from 15 - MSSQL 2008 support is dropped - MSSQL tests now run against locked 2022 version Fixes: https://github.com/go-gitea/gitea/issues/25657 Ref: https://endoflife.date/mysql Ref: https://endoflife.date/postgresql Ref: https://endoflife.date/mssqlserver ## :warning: BREAKING :warning: Support for MySQL 5.7, PostgreSQL 10 and 11, and MSSQL 2008 is dropped. You are encouraged to upgrade to supported versions. --------- Co-authored-by: techknowlogick <techknowlogick@gitea.com>
* Even more `db.DefaultContext` refactor (#27352)JakobDev2023-10-035-6/+8
| | | | | | | | Part of #27065 --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: delvh <dev.lh@web.de>
* Add support for HEAD ref in /src/branch and /src/commit routes (#27384)Kirill Sorokin2023-10-031-0/+4
| | | | | | | | | Add support for HEAD in paths: ``` /src/branch/HEAD/README.md /src/commit/HEAD/README.md ``` Closes #26920
* Test more templates for if they contain an error (#27367)Lunny Xiao2023-10-021-0/+33
|
* Allow get release download files and lfs files with oauth2 token format (#26430)Lunny Xiao2023-10-014-0/+33
| | | | Fix #26165 Fix #25257
* More `db.DefaultContext` refactor (#27265)JakobDev2023-09-291-1/+1
| | | | | | | Part of #27065 This PR touches functions used in templates. As templates are not static typed, errors are harder to find, but I hope I catch it all. I think some tests from other persons do not hurt.
* Fix Bug in Issue Config when only contact links are set (#26521)JakobDev2023-09-282-15/+171
| | | | | | | | | | | | Blank Issues should be enabled if they are not explicit disabled through the `blank_issues_enabled` field of the Issue Config. The Implementation has currently a Bug: If you create a Issue Config file with only `contact_links` and without a `blank_issues_enabled` field, `blank_issues_enabled` is set to false by default. The fix is only one line, but I decided to also improve the tests to make sure there are no other problems with the Implementation. This is a bugfix, so it should be backported to 1.20.
* Another round of `db.DefaultContext` refactor (#27103)JakobDev2023-09-251-1/+1
| | | | | | | Part of #27065 --------- Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Fix review request number and add more tests (#27104)Nanguan Lin2023-09-213-13/+13
| | | | | | | | | | | | | | | | | | | | | fix #27019 ## testfixture yml 1. add issue20(a pr issue) in repo 23, org 17 2. add user15 to team 9 3. add four reviews about issue20 ## test case add two tests that are described with code comments the code before pr #26784 failed the first test <img width="479" alt="image" src="https://github.com/go-gitea/gitea/assets/70063547/1d9b5787-11b4-4c4d-931f-6a9869547f35"> current code failed the second test(as mentioned in #27019) <img width="484" alt="image" src="https://github.com/go-gitea/gitea/assets/70063547/05608055-7587-43d1-bae1-92c688270819"> Any advice is appreciated. --------- Co-authored-by: CaiCandong <50507092+CaiCandong@users.noreply.github.com> Co-authored-by: Giteabot <teabot@gitea.io>
* Change green buttons to primary color (#27099)silverwind2023-09-183-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | I think it's better if the primary actions have primary color instead of green which fits better into the overall single-color UI design. This PR currently replaces every green button with primary: <img width="141" alt="Screenshot 2023-09-16 at 14 07 59" src="https://github.com/go-gitea/gitea/assets/115237/843c1e50-4fb2-4ec6-84ba-0efb9472dcbe"> <img width="161" alt="Screenshot 2023-09-16 at 14 07 51" src="https://github.com/go-gitea/gitea/assets/115237/9442195a-a3b2-4a42-b262-8377d6f5c0d1"> Modal actions now use uncolored/primary instead of previous green/red colors. I also removed the box-shadow on all basic buttons: <img width="259" alt="Screenshot 2023-09-16 at 14 16 39" src="https://github.com/go-gitea/gitea/assets/115237/5beea529-127a-44b0-8d4c-afa7b034a490"> <img width="261" alt="Screenshot 2023-09-16 at 14 17 42" src="https://github.com/go-gitea/gitea/assets/115237/4757f7b2-4d46-49bc-a797-38bb28437b88"> The change currently includes the "Merge PR" button, for which we might want to make an exception to match the icon color there: <img width="442" alt="Screenshot 2023-09-16 at 14 33 53" src="https://github.com/go-gitea/gitea/assets/115237/993ac1a5-c94d-4895-b76c-0d872181a70b">
* Fix token endpoints ignore specified account (#27080)CaiCandong2023-09-181-0/+23
| | | | | | | | | Fix #26234 close #26323 close #27040 --------- Co-authored-by: silverwind <me@silverwind.io>
* Next round of `db.DefaultContext` refactor (#27089)JakobDev2023-09-161-2/+2
| | | Part of #27065
* More refactoring of `db.DefaultContext` (#27083)JakobDev2023-09-152-2/+3
| | | Next step of #27065
* Reduce usage of `db.DefaultContext` (#27073)JakobDev2023-09-141-2/+2
| | | | | | | | | | | | | | Part of #27065 This reduces the usage of `db.DefaultContext`. I think I've got enough files for the first PR. When this is merged, I will continue working on this. Considering how many files this PR affect, I hope it won't take to long to merge, so I don't end up in the merge conflict hell. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Replace 'userxx' with 'orgxx' in all test files when the user type is org ↵Nanguan Lin2023-09-1468-164/+164
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#27052) Currently 'userxx' and 'orgxx' are both used as username in test files when the user type is org, which is confusing. This PR replaces all 'userxx' with 'orgxx' when the user type is org(`user.type==1`). Some non-trivial changes 1. Rename `user3` dir to `org3` in `tests/git-repositories-meta` 2. Change `end` in `issue reference` because 'org3' is one char shorter than 'user3' ![ksnip_20230913-112819](https://github.com/go-gitea/gitea/assets/70063547/442988c5-4cf4-49b8-aa01-4dd6bf0ca954) 3. Change the search result number of `user/repo2` because `user3/repo21` can't be searched now ![ksnip_20230913-112931](https://github.com/go-gitea/gitea/assets/70063547/d9ebeba4-479f-4110-9a85-825efbc981fd) 4. Change the first org name getting from API because the result is ordered by alphabet asc and now `org 17` is before `org25` ![JW8U7NIO(J$H _YCRB36H)T](https://github.com/go-gitea/gitea/assets/70063547/f55a685c-cf24-40e5-a87f-3a2327319548) ![)KFD411O4I8RB5ZOH7E0 Z3](https://github.com/go-gitea/gitea/assets/70063547/a0dc3299-249c-46f6-91cb-d15d4ee88dd5) Other modifications are just find all and replace all. Unit tests with SQLite are all passed. --------- Co-authored-by: caicandong <1290147055@qq.com>
* move repository deletion to service layer (#26948)Lunny Xiao2023-09-083-4/+4
| | | Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Move createrepository from module to service layer (#26927)Lunny Xiao2023-09-065-9/+7
| | | | Repository creation depends on many models, so moving it to service layer is better.
* Artifacts retention and auto clean up (#26131)FuXiaoHei2023-09-061-2/+40
| | | | | | | | | | | | | | Currently, Artifact does not have an expiration and automatic cleanup mechanism, and this feature needs to be added. It contains the following key points: - [x] add global artifact retention days option in config file. Default value is 90 days. - [x] add cron task to clean up expired artifacts. It should run once a day. - [x] support custom retention period from `retention-days: 5` in `upload-artifact@v3`. - [x] artifacts link in actions view should be non-clickable text when expired.
* Refactor secrets modification logic (#26873)KN4CK3R2023-09-051-0/+103
| | | | - Share code between web and api - Add some tests
* Add missing `reqToken()` to notifications endpoints (#26914)JakobDev2023-09-051-0/+6
| | | | | | | | They currently throw a Internal Server Error when you use them without a token. Now they correctly return a `token is required` error. This is no security issue. If you use this endpoints with a token that don't have the correct permission, you get the correct error. This is not affected by this PR.
* Remove duplicated notify mail configuration on tests (#26912)Lunny Xiao2023-09-053-3/+0
| | | | | Extract from #22266 Co-authored-by: Giteabot <teabot@gitea.io>
* Avoid double-unescaping of form value (#26853)wxiaoguang2023-09-012-2/+2
| | | | | | | 1. The old `prepareQueryArg` did double-unescaping of form value. 2. By the way, remove the unnecessary `ctx.Flash = ...` in `MockContext`. Co-authored-by: Giteabot <teabot@gitea.io>
* Move web/api context related testing function into a separate package (#26859)wxiaoguang2023-09-011-36/+36
| | | | | | | | | Just like `models/unittest`, the testing helper functions should be in a separate package: `contexttest` And complete the TODO: > // TODO: move this function to other packages, because it depends on "models" package
* Update team invitation email link (#26550)Jack Hay2023-08-311-6/+313
| | | | | Co-authored-by: Kyle D <kdumontnu@gmail.com> Co-authored-by: Jonathan Tran <jonnytran@gmail.com>
* User details page (#26713)Denys Konovalov2023-08-311-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This PR implements a proposal to clean up the admin users table by moving some information out to a separate user details page (which also displays some additional information). Other changes: - move edit user page from `/admin/users/{id}` to `/admin/users/{id}/edit` -> `/admin/users/{id}` now shows the user details page - show if user is instance administrator as a label instead of a separate column - separate explore users template into a page- and a shared one, to make it possible to use it on the user details page - fix issue where there was no margin between alert message and following content on admin pages <details> <summary>Screenshots</summary> ![grafik](https://github.com/go-gitea/gitea/assets/47871822/1ad57ac9-f20a-45a4-8477-ffe572a41e9e) ![grafik](https://github.com/go-gitea/gitea/assets/47871822/25786ecd-cb9d-4c92-90f4-e7f4292c073b) </details> Partially resolves #25939 --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Expanded minimum RSA Keylength to 3072 (#26604)mainboarder2023-08-281-0/+3
| | | | | | | | | | | | | | | German Federal Office for Information Security requests in its technical guideline BSI TR-02102-1 RSA Keylength not shorter than 3000bits starting 2024, in the year 2023 3000bits as a recommendation. Gitea should request longer RSA Keys by default in favor of security and drop old clients which do not support longer keys. https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Publikationen/TechnischeRichtlinien/TR02102/BSI-TR-02102.pdf?__blob=publicationFile&v=9 - Page 19, Table 1.2 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* add Upload URL to release API (#26663)Earl Warren2023-08-241-0/+40
| | | | | | | | | | | | - Resolves https://codeberg.org/forgejo/forgejo/issues/580 - Return a `upload_field` to any release API response, which points to the API URL for uploading new assets. - Adds unit test. - Adds integration testing to verify URL is returned correctly and that upload endpoint actually works --------- Co-authored-by: Gusted <postmaster@gusted.xyz>
* PATCH branch-protection updates check list even when checks are disabled ↵Infinoid2023-08-241-1/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | (#26351) Fixes: #26333. Previously, this endpoint only updates the `StatusCheckContexts` field when `EnableStatusCheck==true`, which makes it impossible to clear the array otherwise. This patch uses slice `nil`-ness to decide whether to update the list of checks. The field is ignored when either the client explicitly passes in a null, or just omits the field from the json ([which causes `json.Unmarshal` to leave the struct field unchanged](https://go.dev/play/p/Z2XHOILuB1Q)). I think this is a better measure of intent than whether the `EnableStatusCheck` flag was set, because it matches the semantics of other field types. Also adds a test case. I noticed that [`testAPIEditBranchProtection` only checks the branch name](https://github.com/go-gitea/gitea/blob/c1c83dbaec840871c1247f4bc3f875309b0de6bb/tests/integration/api_branch_test.go#L68) and no other fields, so I added some extra `GET` calls and specific checks to make sure the fields are changing properly. I added those checks the existing integration test; is that the right place for it?
* Update minimum password length requirements (#25946)techknowlogick2023-08-211-2/+2
|
* Do not use deprecated log config options by default (#26592)wxiaoguang2023-08-205-10/+5
| | | | | | Simplify the log config * Remove unnecessary `ROUTER` config, it defaults to the `MODE`. * `XORM` config was deprecated
* Fix NuGet search endpoints (#25613)KN4CK3R2023-08-141-9/+9
| | | | | | | | | Fixes #25564 Fixes #23191 - Api v2 search endpoint should return only the latest version matching the query - Api v3 search endpoint should return `take` packages not package versions