Skip to content
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

configstore: add ability to org members to restart stop cancel a project run #446

Merged
merged 1 commit into from
Oct 16, 2023

Conversation

alessandro-sorint
Copy link
Contributor

@alessandro-sorint alessandro-sorint commented Oct 10, 2023

This patch adds a project option to permit org members to execute run actions (restart/stop/cancel)
The MembersCanPerformRunActions option has been added to the project type. The API will permit to set it to true on project create/update only for projects belonging to an organization and will return an error when on user's projects.

fix #428

Copy link
Member

@sgotti sgotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alessandro-sorint Thanks for the PR.

  • The commit title and description aren't detailing what it does (do not write the code changes, but the new behavior with more details).

  • Tests for this new behavior aren't implemented.

SkipSSHHostKeyCheck bool
PassVarsToForkedPR bool
DefaultBranch string
CanMembersPerformRunActions bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MembersCanPerformRunActions

SkipSSHHostKeyCheck bool
PassVarsToForkedPR bool
DefaultBranch string
CanMembersPerformRunActions bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Detail what "Run Actions" are.


func (d *DB) migrateV3(tx *sql.Tx) error {
var ddlPostgres = []string{
"CREATE TABLE new_project (id varchar NOT NULL, revision bigint NOT NULL, creation_time timestamptz NOT NULL, update_time timestamptz NOT NULL, name varchar NOT NULL, parent_kind varchar NOT NULL, parent_id varchar NOT NULL, secret varchar NOT NULL, visibility varchar NOT NULL, remote_repository_config_type varchar NOT NULL, remote_source_id varchar NOT NULL, linked_account_id varchar NOT NULL, repository_id varchar NOT NULL, repository_path varchar NOT NULL, ssh_private_key varchar NOT NULL, skip_ssh_host_key_check boolean NOT NULL, webhook_secret varchar NOT NULL, pass_vars_to_forked_pr boolean NOT NULL, default_branch varchar NOT NULL, can_members_perform_run_actions boolean NOT NULL, PRIMARY KEY (id))",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is a new table creation and copy really needed for postgres?

Comment on lines 186 to 270
func (h *ActionHandler) CanAuthUserDeleteLogs(ctx context.Context, groupType scommon.GroupType, ref string) (bool, string, error) {
var ownerType cstypes.ObjectKind
var refID string
var ownerID string
switch groupType {
case scommon.GroupTypeProject:
p, _, err := h.configstoreClient.GetProject(ctx, ref)
if err != nil {
return false, "", util.NewAPIError(util.KindFromRemoteError(err), err)
}
refID = p.ID
ownerType = p.OwnerType
ownerID = p.OwnerID
case scommon.GroupTypeUser:
u, _, err := h.configstoreClient.GetUser(ctx, ref)
if err != nil {
return false, "", util.NewAPIError(util.KindFromRemoteError(err), err)
}

// user direct runs
refID = u.ID
ownerType = cstypes.ObjectKindUser
ownerID = u.ID
}

isProjectOwner, err := h.IsAuthUserProjectOwner(ctx, ownerType, ownerID)
if err != nil {
return false, "", errors.Wrapf(err, "failed to determine ownership")
}
if !isProjectOwner {
return false, "", nil
}
return true, refID, nil
}

func (h *ActionHandler) CanAuthUserDoRunActions(ctx context.Context, groupType scommon.GroupType, ref string) (bool, string, error) {
var ownerType cstypes.ObjectKind
var refID string
var ownerID string
var p *csapitypes.Project
switch groupType {
case scommon.GroupTypeProject:
var err error
p, _, err = h.configstoreClient.GetProject(ctx, ref)
if err != nil {
return false, "", util.NewAPIError(util.KindFromRemoteError(err), err)
}
refID = p.ID
ownerType = p.OwnerType
ownerID = p.OwnerID
case scommon.GroupTypeUser:
u, _, err := h.configstoreClient.GetUser(ctx, ref)
if err != nil {
return false, "", util.NewAPIError(util.KindFromRemoteError(err), err)
}

// user direct runs
refID = u.ID
ownerType = cstypes.ObjectKindUser
ownerID = u.ID
}

isAdmin := common.IsUserAdmin(ctx)
if isAdmin {
return true, refID, nil
}

if ownerType == cstypes.ObjectKindOrg && p.CanMembersPerformRunActions {
userID := common.CurrentUserID(ctx)
isUserMember, err := h.IsUserOrgMember(ctx, userID, ownerID)
if err != nil {
return false, "", errors.Wrapf(err, "failed to determine ownership")
}
return isUserMember, "", nil
}

isProjectOwner, err := h.IsAuthUserProjectOwner(ctx, ownerType, ownerID)
if err != nil {
return false, "", errors.Wrapf(err, "failed to determine ownership")
}
if !isProjectOwner {
return false, "", nil
}
return true, refID, nil
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really needed to duplicate all of this code?

@@ -167,7 +167,7 @@ type DeleteLogsRequest struct {
}

func (h *ActionHandler) DeleteLogs(ctx context.Context, req *DeleteLogsRequest) error {
canDoRunActions, groupID, err := h.CanAuthUserDoRunActions(ctx, req.GroupType, req.Ref)
canDoRunActions, groupID, err := h.CanAuthUserDeleteLogs(ctx, req.GroupType, req.Ref)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have you split CanAuthUserDoRunActions in two functions if they do the same thing?

Copy link
Member

@sgotti sgotti Oct 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should test the migration to v3. So at least explicitly define the new field added with the default value.

@alessandro-sorint alessandro-sorint changed the title configstore: add project run actions auth setting for org members configstore: add ability to org members to restart stop cancel a project run Oct 11, 2023
@alessandro-sorint
Copy link
Contributor Author

  • Tests for this new behavior aren't implemented.

@sgotti I implemented TestProjectRunActions in integration test, do you mean other?

@@ -1080,7 +1081,7 @@ func TestUpdateProject(t *testing.T) {
}
}

func createProject(ctx context.Context, t *testing.T, giteaClient *gitea.Client, gwClient *gwclient.Client) (*gitea.Repository, *gwapitypes.ProjectResponse) {
func createProject(ctx context.Context, t *testing.T, giteaClient *gitea.Client, gwClient *gwclient.Client, parentRef string, membersCanPerformRunActions bool) (*gitea.Repository, *gwapitypes.ProjectResponse) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of increasing the number of function arguments I'll use the With... pattern

func (d *DB) migrateV3(tx *sql.Tx) error {
var ddlPostgres = []string{
"ALTER TABLE project ADD COLUMN members_can_perform_run_actions boolean NOT NULL DEFAULT false",
"ALTER TABLE project ALTER COLUMN members_can_perform_run_actions DROP DEFAULT",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this statement really needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sgotti in the first statement if I remove DEFAULT false the error is pq: column "can_members_perform_run_actions" of relation "project" contains null values, because we have already sono project rows in db.
In the second statement I remove DEFAULT to have the same shema of V3.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, It just doesn't looks very clear. I'll prefer to do this in the standard 3 ways steps: Add column without non null constraint, update column with default values, add null constraint to the column.


var ddlSqlite3 = []string{
"CREATE TABLE new_project (id varchar NOT NULL, revision bigint NOT NULL, creation_time timestamp NOT NULL, update_time timestamp NOT NULL, name varchar NOT NULL, parent_kind varchar NOT NULL, parent_id varchar NOT NULL, secret varchar NOT NULL, visibility varchar NOT NULL, remote_repository_config_type varchar NOT NULL, remote_source_id varchar NOT NULL, linked_account_id varchar NOT NULL, repository_id varchar NOT NULL, repository_path varchar NOT NULL, ssh_private_key varchar NOT NULL, skip_ssh_host_key_check integer NOT NULL, webhook_secret varchar NOT NULL, pass_vars_to_forked_pr integer NOT NULL, default_branch varchar NOT NULL, members_can_perform_run_actions integer NOT NULL, PRIMARY KEY (id))",
"INSERT INTO new_project SELECT *,0 AS members_can_perform_run_actions FROM project",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sqlite3 should also recognize true and false.


var ddlSqlite3 = []string{
"CREATE TABLE new_project (id varchar NOT NULL, revision bigint NOT NULL, creation_time timestamp NOT NULL, update_time timestamp NOT NULL, name varchar NOT NULL, parent_kind varchar NOT NULL, parent_id varchar NOT NULL, secret varchar NOT NULL, visibility varchar NOT NULL, remote_repository_config_type varchar NOT NULL, remote_source_id varchar NOT NULL, linked_account_id varchar NOT NULL, repository_id varchar NOT NULL, repository_path varchar NOT NULL, ssh_private_key varchar NOT NULL, skip_ssh_host_key_check integer NOT NULL, webhook_secret varchar NOT NULL, pass_vars_to_forked_pr integer NOT NULL, default_branch varchar NOT NULL, members_can_perform_run_actions integer NOT NULL, PRIMARY KEY (id))",
"INSERT INTO new_project SELECT *,0 AS members_can_perform_run_actions FROM project",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a space after select *,

services/configstore/api/types/project.go Show resolved Hide resolved
tests/setup_test.go Show resolved Hide resolved
@sgotti
Copy link
Member

sgotti commented Oct 11, 2023

@sgotti I implemented TestProjectRunActions in integration test, do you mean other?

Sorry, I missed them. Can you also add something in configstore tests for TestProjectUpdate (also once the behavior of an user project has been clarified)?

@@ -207,6 +218,22 @@ func (h *ActionHandler) CanAuthUserDoRunActions(ctx context.Context, groupType s
ownerID = u.ID
}

if authType == authTypeRunAction {
Copy link
Member

@sgotti sgotti Oct 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you aren't checking the other action types

Comment on lines 222 to 235
isAdmin := common.IsUserAdmin(ctx)
if isAdmin {
return true, refID, nil
}

if ownerType == cstypes.ObjectKindOrg && p.MembersCanPerformRunActions {
userID := common.CurrentUserID(ctx)
isUserMember, err := h.IsUserOrgMember(ctx, userID, ownerID)
if err != nil {
return false, "", errors.Wrapf(err, "failed to determine ownership")
}
return isUserMember, "", nil
}
}
Copy link
Member

@sgotti sgotti Oct 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is creating its own branch, but the branch can continue. It also uses IsUserAdmin instead of IsAuthUserProjectOwner like done after. So it looks confusing and wrong.

Why don't you just use this check? `isProjectOwner || (isUserOrgMember && p.MembersCanPerformRunActions) when the actionType is RunAction?

@@ -182,13 +183,23 @@ func (h *ActionHandler) CanAuthUserGetRun(ctx context.Context, groupType scommon
return true, refID, nil
}

func (h *ActionHandler) CanAuthUserDoRunActions(ctx context.Context, groupType scommon.GroupType, ref string) (bool, string, error) {
type authType string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actionType

@alessandro-sorint
Copy link
Contributor Author

alessandro-sorint commented Oct 12, 2023

For user project the behavioir in CanAuthUserDoRunActions func is to ignore MembersCanPerformRunActions.
Should I also add a check where is not possible to set true in MembersCanPerformRunActions field for a user project? (with relative tests)

Yes, let's avoid changing this to true for user projects.

@@ -59,6 +59,29 @@ func (h *ActionHandler) ValidateProjectReq(ctx context.Context, req *CreateUpdat
return util.NewAPIError(util.ErrBadRequest, errors.Errorf("empty remote repository path"))
}
}

err := h.d.Do(ctx, func(tx *sql.Tx) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be done here creating an additional transaction but inside Create and Update project.

}

if p.OwnerType == cstypes.ObjectKindUser && p.MembersCanPerformRunActions {
return nil, util.NewAPIError(util.ErrBadRequest, errors.Errorf("can't set MembersCanPerformRunActions true for user projects"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check should be done in the configstore. (Like already done above in this patch, also if in the wrong place).

return errors.WithStack(err)
}
if ownerType == types.ObjectKindUser && req.MembersCanPerformRunActions {
return util.NewAPIError(util.ErrBadRequest, errors.Errorf("can't set MembersCanPerformRunActions true for user projects"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot set MembersCanPerformRunActions on an user project.

@@ -93,6 +116,8 @@ type CreateUpdateProjectRequest struct {
SkipSSHHostKeyCheck bool
PassVarsToForkedPR bool
DefaultBranch string
//MembersCanPerformRunActions define if users of the organization can restart stop cancel a project run
Copy link
Member

@sgotti sgotti Oct 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MembersCanPerformRunActions defines if project organization members can restart/stop/cancel a project run

remoteErrorBadRequest = "remote error badrequest"
remoteErrorNotExist = "remote error notexist"
remoteErrorBadRequest = "remote error badrequest"
remoteErrorForbiddenRequest = "remote error forbidden"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also change the already existing inline strings.

} else {
if !isProjectOwner {
return false, "", nil
}
}
return true, refID, nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have both a default return and a return at the end of the first branch
You should remove the default return or remove the return at the of the first branch.

internal/services/gateway/action/auth.go Show resolved Hide resolved
@@ -93,6 +93,8 @@ type CreateUpdateProjectRequest struct {
SkipSSHHostKeyCheck bool
PassVarsToForkedPR bool
DefaultBranch string
//MembersCanPerformRunActions define if users of the organization can restart/stop/cancel a project run
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// MembersCanPerformRunActions defines if project organization members can restart/stop/cancel a project run

return errors.WithStack(err)
}
if ownerType == types.ObjectKindUser && req.MembersCanPerformRunActions {
return util.NewAPIError(util.ErrBadRequest, errors.Errorf("Cannot set MembersCanPerformRunActions on an user project."))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

obviously the first letter of errors has never been capital so
s/Cannot/cannot/

Comment on lines 107 to 109
remoteErrorUnauthorized = "remote error unauthorized"
remoteErrorUnknown = "unknown api error (status: 403)"
remoteErrorInternal = "remote error internal"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant only the strings for the remoteErrorForbidden you added. The others should be done in another PR...

remoteErrorBadRequest = "remote error badrequest"
remoteErrorNotExist = "remote error notexist"
remoteErrorBadRequest = "remote error badrequest"
remoteErrorForbiddenRequest = "remote error forbidden"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remoteErrorForbidden


push(t, config, giteaRepo.CloneURL, giteaToken, "commit", false)

// test org run actions user owner
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// test org run actions executed by an user that's organization owner

t.Fatalf("unexpected err: %v", err)
}

// test org run actions user member
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// test org run actions executed by an user that's organization moember with project MembersCanPerformRunActions set to true

t.Fatalf("unexpected err: %v", err)
}

// test org run actions user not member
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// test org run actions executed by an user that isn't organization member

`
expectedErr := remoteErrorForbiddenRequest

t.Run("test org run actions", func(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// test run actions on org's project

}
})

t.Run("test user run actions", func(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// test run actions on user's project

tests/setup_test.go Show resolved Hide resolved
@sgotti
Copy link
Member

sgotti commented Oct 13, 2023

@alessandro-sorint
The commit and PR (since it's a single commit) description isn't detailing what it does and the behavior. Please add more details.

Comment on lines 1033 to 1092
tests := []struct {
name string
passVarsToForkedPR bool
expectedPre bool
expectedPost bool
name string
passVarsToForkedPR bool
expectedPre bool
expectedPost bool
membersCanPerformRunActions bool
}{
{
name: "test project update with pass-vars-to-forked-pr true",
passVarsToForkedPR: true,
expectedPre: false,
expectedPost: true,
name: "test project update with pass-vars-to-forked-pr true and membersCanPerformRunActions false ",
passVarsToForkedPR: true,
expectedPre: false,
expectedPost: true,
membersCanPerformRunActions: false,
},
{
name: "test project update with pass-vars-to-forked-pr false",
passVarsToForkedPR: false,
expectedPre: false,
expectedPost: false,
name: "test project update with pass-vars-to-forked-pr false and membersCanPerformRunActions false",
passVarsToForkedPR: false,
expectedPre: false,
expectedPost: false,
membersCanPerformRunActions: false,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
dir := t.TempDir()

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

sc := setup(ctx, t, dir, withGitea(true))
defer sc.stop()

giteaAPIURL := fmt.Sprintf("http://%s:%s", sc.gitea.HTTPListenAddress, sc.gitea.HTTPPort)

giteaToken, token := createLinkedAccount(ctx, t, sc.gitea, sc.config)

giteaClient, err := gitea.NewClient(giteaAPIURL, gitea.SetToken(giteaToken))
if err != nil {
t.Fatalf("unexpected err: %v", err)
}

gwClient := gwclient.NewClient(sc.config.Gateway.APIExposedURL, token)

_, project := createProject(ctx, t, giteaClient, gwClient)
if project.PassVarsToForkedPR != tt.expectedPre {
t.Fatalf("expected PassVarsToForkedPR %v, got %v (pre-update)", tt.expectedPre, project.PassVarsToForkedPR)
}
if project.MembersCanPerformRunActions != tt.membersCanPerformRunActions {
t.Fatalf("expected MembersCanPerformRunActions %v, got %v (pre-update)", tt.membersCanPerformRunActions, project.MembersCanPerformRunActions)
}
project = updateProject(ctx, t, giteaClient, gwClient, project.ID, tt.passVarsToForkedPR)
if project.PassVarsToForkedPR != tt.expectedPost {
t.Fatalf("expected PassVarsToForkedPR %v, got %v (port-update)", tt.expectedPost, project.PassVarsToForkedPR)
}
if project.MembersCanPerformRunActions != tt.membersCanPerformRunActions {
t.Fatalf("expected MembersCanPerformRunActions %v, got %v (port-update)", tt.membersCanPerformRunActions, project.MembersCanPerformRunActions)
}
})
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mix of tests matrix and single sub tests is confusing. Also the pre/post stuff could be removed. Probably the 2 tests in the matrix could be just changed to standard sub tests.

t.Fatalf("unexpected err: %v", err)
}

// test org run actions executed by an user that's organization moember with project MembersCanPerformRunActions set to true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moember typo

t.Fatalf("expected err %v, got err: %v", expectedErr, err)
}

// test MembersCanPerformRunActions false user member
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

}
})

t.Run("// test run actions on user's project", func(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

starting // ?

Comment on lines 6373 to 6383
_, _, err = gwAdminClient.CreateUser(ctx, &gwapitypes.CreateUserRequest{UserName: agolaUser03})
if err != nil {
t.Fatalf("unexpected err: %v", err)
}

token, _, err = gwAdminClient.CreateUserToken(ctx, agolaUser03, &gwapitypes.CreateUserTokenRequest{TokenName: "testtoken"})
if err != nil {
t.Fatalf("unexpected err: %v", err)
}

gwUser03Client := gwclient.NewClient(sc.config.Gateway.APIExposedURL, token.Token)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

users's creation and related stuffs at the start of the test.

Comment on lines 6489 to 6499
_, _, err = gwAdminClient.CreateUser(ctx, &gwapitypes.CreateUserRequest{UserName: agolaUser02})
if err != nil {
t.Fatalf("unexpected err: %v", err)
}

token, _, err := gwAdminClient.CreateUserToken(ctx, agolaUser02, &gwapitypes.CreateUserTokenRequest{TokenName: "testtoken"})
if err != nil {
t.Fatalf("unexpected err: %v", err)
}

gwUser02Client := gwclient.NewClient(sc.config.Gateway.APIExposedURL, token.Token)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

users's creation and related stuffs at the start of the test.

Comment on lines 6484 to 6488
gwAdminClient := gwclient.NewClient(sc.config.Gateway.APIExposedURL, sc.config.Gateway.AdminToken)
if err != nil {
t.Fatalf("unexpected err: %v", err)
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

users's creation and related stuffs at the start of the test.

tests/setup_test.go Show resolved Hide resolved

_, project := createProject(ctx, t, giteaClient, gwClient)
if project.PassVarsToForkedPR != false {
t.Fatalf("expected PassVarsToForkedPR false, got %v (pre-update)", project.PassVarsToForkedPR)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove (pre-update)


project = updateProject(ctx, t, giteaClient, gwClient, project.ID, false)
if project.PassVarsToForkedPR != false {
t.Fatalf("expected PassVarsToForkedPR false, got %v (pre-update)", project.PassVarsToForkedPR)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove (pre-update)


project = updateProject(ctx, t, giteaClient, gwClient, project.ID, true)
if project.PassVarsToForkedPR != true {
t.Fatalf("expected PassVarsToForkedPR false, got %v (pre-update)", project.PassVarsToForkedPR)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove (pre-update)

if project.PassVarsToForkedPR != tt.expectedPre {
t.Fatalf("expected PassVarsToForkedPR %v, got %v (pre-update)", tt.expectedPre, project.PassVarsToForkedPR)
if project.MembersCanPerformRunActions != false {
t.Fatalf("expected MembersCanPerformRunActions false, got %v (pre-update)", project.MembersCanPerformRunActions)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove (pre-update)

tests/setup_test.go Show resolved Hide resolved
tests/setup_test.go Show resolved Hide resolved
t.Fatalf("expected PassVarsToForkedPR false, got %v (pre-update)", project.PassVarsToForkedPR)
}

project = updateProject(ctx, t, giteaClient, gwClient, project.ID, true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove updateProject function and directly call the api here as done in other tests.

…ect run

This patch adds a project option to permit org members to execute run actions (restart/stop/cancel)
The `MembersCanPerformRunActions` option has been added to the project type.
The API will permit to set it to true on project create/update only for projects belonging to an organization and will return an error when on user's projects.
@sgotti sgotti merged commit 7c80cf2 into agola-io:master Oct 16, 2023
1 check passed
@alessandro-sorint alessandro-sorint deleted the issue-428 branch October 17, 2023 07:00
raynasorint added a commit to raynasorint/agola-web that referenced this pull request Nov 28, 2023
add an ui checkbox to let the project owner enable the project option to let members perform run actions as implemented in agola-io/agola#446
raynasorint added a commit to raynasorint/agola-web that referenced this pull request Nov 28, 2023
add an ui checkbox to let the project owner enable the project option to let members perform run actions as implemented in agola-io/agola#446
raynasorint added a commit to raynasorint/agola-web that referenced this pull request Nov 30, 2023
add an ui checkbox to let the project owner enable the project option to let members perform run actions as implemented in agola-io/agola#446
raynasorint added a commit to raynasorint/agola-web that referenced this pull request Dec 1, 2023
add an ui checkbox to let the project owner enable the project option to let members perform run actions as implemented in agola-io/agola#446
raynasorint added a commit to raynasorint/agola-web that referenced this pull request Dec 5, 2023
add an ui checkbox to let the project owner enable the project option to let members perform run actions as implemented in agola-io/agola#446
raynasorint added a commit to raynasorint/agola-web that referenced this pull request Dec 5, 2023
add an ui checkbox to let the project owner enable the project option to let members perform run actions as implemented in agola-io/agola#446
raynasorint added a commit to raynasorint/agola-web that referenced this pull request Dec 14, 2023
add an ui checkbox to let the project owner enable the project option to let members perform run actions as implemented in agola-io/agola#446
raynasorint added a commit to raynasorint/agola-web that referenced this pull request Dec 20, 2023
add an ui checkbox to let the project owner enable the project option to let members perform run actions as implemented in agola-io/agola#446
raynasorint added a commit to raynasorint/agola-web that referenced this pull request Dec 27, 2023
add an ui checkbox to let the project owner enable the project option to let members perform run actions as implemented in agola-io/agola#446
raynasorint added a commit to raynasorint/agola-web that referenced this pull request Jan 12, 2024
add an ui checkbox to let the project owner enable the project option to let members perform run actions as implemented in agola-io/agola#446
raynasorint added a commit to raynasorint/agola-web that referenced this pull request Jan 15, 2024
add an ui checkbox to let the project owner enable the project option to let members perform run actions as implemented in agola-io/agola#446
raynasorint added a commit to raynasorint/agola-web that referenced this pull request Jan 15, 2024
add an ui checkbox to let the project owner enable the project option to let members perform run actions as implemented in agola-io/agola#446
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Organization rules for runs start/stop
2 participants