@@ -12,19 +12,23 @@ import (
1212 repo_model "code.gitea.io/gitea/models/repo"
1313 "code.gitea.io/gitea/models/unittest"
1414 user_model "code.gitea.io/gitea/models/user"
15+ "code.gitea.io/gitea/modules/setting"
16+ "code.gitea.io/gitea/modules/test"
1517 "code.gitea.io/gitea/tests"
1618)
1719
1820func TestAPIEditReleaseAttachmentWithUnallowedFile (t * testing.T ) {
21+ // Limit the allowed release types (since by default there is no restriction)
22+ defer test .MockVariableValue (& setting .Repository .Release .AllowedTypes , ".exe" )()
1923 defer tests .PrepareTestEnv (t )()
2024
21- attachment := unittest .AssertExistsAndLoadBean (t , & repo_model.Attachment {ID : 11 })
22- repo := unittest .AssertExistsAndLoadBean (t , & repo_model.Repository {ID : attachment .RepoID })
25+ attachment := unittest .AssertExistsAndLoadBean (t , & repo_model.Attachment {ID : 9 })
2326 release := unittest .AssertExistsAndLoadBean (t , & repo_model.Release {ID : attachment .ReleaseID })
27+ repo := unittest .AssertExistsAndLoadBean (t , & repo_model.Repository {ID : attachment .RepoID })
2428 repoOwner := unittest .AssertExistsAndLoadBean (t , & user_model.User {ID : repo .OwnerID })
2529
2630 session := loginUser (t , repoOwner .Name )
27- token := getTokenForLoggedInUser (t , session , auth_model .AccessTokenScopeWriteIssue )
31+ token := getTokenForLoggedInUser (t , session , auth_model .AccessTokenScopeWriteRepository )
2832
2933 filename := "file.bad"
3034 urlStr := fmt .Sprintf ("/api/v1/repos/%s/%s/releases/%d/assets/%d" , repoOwner .Name , repo .Name , release .ID , attachment .ID )
0 commit comments