diff --git a/tests/integration/actions_job_token_test.go b/tests/integration/actions_job_token_test.go index e57818dee5..60b6ee8c2b 100644 --- a/tests/integration/actions_job_token_test.go +++ b/tests/integration/actions_job_token_test.go @@ -174,7 +174,11 @@ func testActionsTokenPermissionsMode(u *url.URL, mode string, expectReadOnly boo var sha string // Test Write Access - context.ExpectedCode = util.Iif(expectReadOnly, http.StatusForbidden, http.StatusCreated) + if expectReadOnly { + context.ExpectedCode = http.StatusForbidden + } else { + context.ExpectedCode = 0 + } t.Run("API Create File", doAPICreateFile(context, "test-permissions.txt", &structs.CreateFileOptions{ FileOptions: structs.FileOptions{ NewBranchName: "new-branch-permissions", @@ -187,7 +191,11 @@ func testActionsTokenPermissionsMode(u *url.URL, mode string, expectReadOnly boo })) // Test Delete Access - context.ExpectedCode = util.Iif(expectReadOnly, http.StatusForbidden, http.StatusNoContent) + if expectReadOnly { + context.ExpectedCode = http.StatusForbidden + } else { + context.ExpectedCode = 0 + } if !expectReadOnly { // Clean up created file if we had write access t.Run("API Delete File", func(t *testing.T) { diff --git a/tests/integration/api_helper_for_declarative_test.go b/tests/integration/api_helper_for_declarative_test.go index d7dcad953c..b30cdfd0fc 100644 --- a/tests/integration/api_helper_for_declarative_test.go +++ b/tests/integration/api_helper_for_declarative_test.go @@ -374,24 +374,6 @@ func doAPICreateFile(ctx APITestContext, treepath string, options *api.CreateFil } } -func doAPIDeleteFile(ctx APITestContext, treepath string, options *api.DeleteFileOptions, callback ...func(*testing.T, api.FileDeleteResponse)) func(*testing.T) { - return func(t *testing.T) { - req := NewRequestWithJSON(t, "DELETE", fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s", ctx.Username, ctx.Reponame, treepath), &options). - AddTokenAuth(ctx.Token) - if ctx.ExpectedCode != 0 { - ctx.Session.MakeRequest(t, req, ctx.ExpectedCode) - return - } - resp := ctx.Session.MakeRequest(t, req, http.StatusOK) - - var contents api.FileDeleteResponse - DecodeJSON(t, resp, &contents) - if len(callback) > 0 { - callback[0](t, contents) - } - } -} - func doAPICreateOrganization(ctx APITestContext, options *api.CreateOrgOption, callback ...func(*testing.T, api.Organization)) func(t *testing.T) { return func(t *testing.T) { req := NewRequestWithJSON(t, "POST", "/api/v1/orgs", &options).