mirror of
https://github.com/go-gitea/gitea.git
synced 2026-01-21 04:45:23 +01:00
CrossRepoMode tests
This commit is contained in:
parent
2480c30847
commit
f5c577536d
@ -320,7 +320,7 @@ type ActionsConfig struct {
|
||||
MaxTokenPermissions *ActionsTokenPermissions `json:"max_token_permissions,omitempty"`
|
||||
// CrossRepoMode indicates which repos in the org can be accessed (none, all, or selected)
|
||||
CrossRepoMode ActionsCrossRepoMode `json:"cross_repo_mode,omitempty"`
|
||||
// AllowedCrossRepoIDs is a list of specific repo IDs that can be accessed cross-repo (empty means all if AllowCrossRepoAccess is true)
|
||||
// AllowedCrossRepoIDs is a list of specific repo IDs that can be accessed cross-repo (only used if CrossRepoMode is ActionsCrossRepoModeSelected)
|
||||
AllowedCrossRepoIDs []int64 `json:"allowed_cross_repo_ids,omitempty"`
|
||||
// OverrideOrgConfig indicates if this repository should override the organization-level configuration
|
||||
OverrideOrgConfig bool `json:"override_org_config,omitempty"`
|
||||
|
||||
@ -510,6 +510,32 @@ func TestActionsCrossRepoAccess(t *testing.T) {
|
||||
writeReq.Header.Set("Authorization", "Bearer "+task.Token)
|
||||
MakeRequest(t, writeReq, http.StatusUnauthorized)
|
||||
})
|
||||
|
||||
// 7. Test Cross-Repo Access - Specific Repositories
|
||||
t.Run("Cross-Repo Access - Specific Repositories", func(t *testing.T) {
|
||||
// Set mode to Selected with ONLY repo-B
|
||||
require.NoError(t, actions_model.SetOrgActionsConfig(t.Context(), org.ID, &repo_model.ActionsConfig{
|
||||
CrossRepoMode: repo_model.ActionsCrossRepoModeSelected,
|
||||
AllowedCrossRepoIDs: []int64{repoBID},
|
||||
}))
|
||||
|
||||
// Access to repo-B should succeed
|
||||
testCtx.Reponame = "repo-B"
|
||||
testCtx.ExpectedCode = http.StatusOK
|
||||
doAPIGetRepository(testCtx, func(t *testing.T, r structs.Repository) {
|
||||
assert.Equal(t, "repo-B", r.Name)
|
||||
})(t)
|
||||
|
||||
// Remove repo-B from allowed list
|
||||
require.NoError(t, actions_model.SetOrgActionsConfig(t.Context(), org.ID, &repo_model.ActionsConfig{
|
||||
CrossRepoMode: repo_model.ActionsCrossRepoModeSelected,
|
||||
AllowedCrossRepoIDs: []int64{}, // Empty list
|
||||
}))
|
||||
|
||||
// Access to repo-B should fail (404)
|
||||
testCtx.ExpectedCode = http.StatusNotFound
|
||||
doAPIGetRepository(testCtx, nil)(t)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user