- Notifications
You must be signed in to change notification settings - Fork676
test: add api integration test for ci_cd_token allowlist#2797
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Closed
TimKnight-DWP wants to merge19 commits intopython-gitlab:feat/job-token-scope-allowlistfromTimKnight-DWP:feat/job-token-scope-allowlist
Uh oh!
There was an error while loading.Please reload this page.
Closed
Changes fromall commits
Commits
Show all changes
19 commits Select commitHold shift + click to select a range
48726fd
chore(deps): update all non-major dependencies
renovate[bot]f59aee3
chore(deps): update dependency black to v24
renovate[bot]4e68d32
chore: adapt style for black v24
nejch7ec3189
fix(cli): allow exclusive arguments as optional (#2770)
Sjordd2be1f7
chore(deps): update codecov/codecov-action action to v4
renovate[bot]7dc2fa6
chore(deps): update all non-major dependencies
renovate[bot]3501716
chore: update version of `black` for `pre-commit`
JohnVillalovos35d2aec
chore(deps): update dependency pytest-docker to v3
renovate[bot]253babb
chore(deps): update dependency pytest to v8
renovate[bot]f6fd02d
chore(deps): update dependency furo to v2024
renovate[bot]c631eeb
docs(artifacts): Fix argument indentation
maxnoe9440a32
fix(api): update manual job status when playing it
1acea867c48
feat(api): allow updating protected branches (#2771)
Sjord3c4b27e
chore(deps): update all non-major dependencies
renovate[bot]e11d889
chore(deps): update python-semantic-release/python-semantic-release a…
renovate[bot]9596e09
feat(job_token_scope): support job token access allowlist API
nejch4203bec
test: add api integration test for ci_cd_token allowlist
TimKnight-DWPe2cae65
test: skip in Gitlab 15
TimKnight-DWP44a354a
Merge branch 'feat/job-token-scope-allowlist' into feat/job-token-sco…
TimKnight-DWPFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
2 changes: 1 addition & 1 deletion.github/workflows/docs.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion.github/workflows/release.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions.github/workflows/test.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions.pre-commit-config.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletionsdocs/gl_objects/protected_branches.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
6 changes: 2 additions & 4 deletionsgitlab/_backends/protocol.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletiongitlab/client.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -40,7 +40,6 @@ | ||
class Gitlab: | ||
"""Represents a GitLab server connection. | ||
Args: | ||
9 changes: 9 additions & 0 deletionsgitlab/v4/cli.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletiongitlab/v4/objects/artifacts.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletionsgitlab/v4/objects/audit_events.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
13 changes: 10 additions & 3 deletionsgitlab/v4/objects/branches.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletionsgitlab/v4/objects/deployments.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletionsgitlab/v4/objects/features.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletiongitlab/v4/objects/job_token_scope.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletiongitlab/v4/objects/jobs.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletionsgitlab/v4/objects/merge_requests.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletionsgitlab/v4/objects/projects.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -2,6 +2,7 @@ | ||
GitLab API: | ||
https://docs.gitlab.com/ee/api/projects.html | ||
""" | ||
from typing import ( | ||
Any, | ||
Callable, | ||
1 change: 1 addition & 0 deletionsgitlab/v4/objects/repositories.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletionsgitlab/v4/objects/secure_files.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletionsgitlab/v4/objects/users.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletionsgitlab/v4/objects/variables.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletionrequirements-docker.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
-r requirements.txt | ||
-r requirements-test.txt | ||
pytest-docker==3.1.1 |
2 changes: 1 addition & 1 deletionrequirements-docs.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
-r requirements.txt | ||
furo==2024.1.29 | ||
jinja2==3.1.3 | ||
myst-parser==2.0.0 | ||
sphinx==7.2.6 | ||
10 changes: 5 additions & 5 deletionsrequirements-lint.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
-r requirements.txt | ||
argcomplete==2.0.0 | ||
black==24.1.1 | ||
commitizen==3.14.1 | ||
flake8==7.0.0 | ||
isort==5.13.2 | ||
mypy==1.8.0 | ||
pylint==3.0.3 | ||
pytest==8.0.0 | ||
responses==0.24.1 | ||
types-PyYAML==6.0.12.12 | ||
types-requests==2.31.0.20240125 | ||
types-setuptools==69.0.0.20240125 |
2 changes: 1 addition & 1 deletionrequirements-precommit.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
pre-commit==3.6.1 |
4 changes: 2 additions & 2 deletionsrequirements-test.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
-r requirements.txt | ||
build==1.0.3 | ||
coverage==7.4.1 | ||
pytest-console-scripts==1.4.1 | ||
pytest-cov==4.1.0 | ||
pytest-github-actions-annotate-failures==0.2.0 | ||
pytest==8.0.0 | ||
PyYaml==6.0.1 | ||
responses==0.24.1 | ||
wheel==0.42.0 |
1 change: 1 addition & 0 deletionstests/functional/api/test_keys.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -2,6 +2,7 @@ | ||
GitLab API: | ||
https://docs.gitlab.com/ce/api/keys.html | ||
""" | ||
import base64 | ||
import hashlib | ||
1 change: 1 addition & 0 deletionstests/functional/api/test_packages.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletionstests/functional/api/test_project_job_token_scope.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import pytest | ||
# TODO: can be enabled when https://github.com/python-gitlab/python-gitlab/pull/2790 merged | ||
@pytest.mark.xfail(reason="project job_token_scope api only in 16.*") | ||
def test_add_project_to_job_token_scope_allowlist(gl, project): | ||
project_to_add = gl.projects.create({"name": "Ci_Cd_token_add_proj"}) | ||
scope = project.job_token_scope.get() | ||
resp = scope.allowlist.create({"target_project_id": project_to_add.id}) | ||
assert resp.source_project_id == project.id | ||
assert resp.target_project_id == project_to_add.id | ||
project_to_add.delete() | ||
@pytest.mark.xfail(reason="project job_token_scope api only in 16.*") | ||
def test_projects_job_token_scope_allowlist_contains_added_project_name(gl, project): | ||
scope = project.job_token_scope.get() | ||
assert len(scope.allowlist.list()) == 0 | ||
project_name = "Ci_Cd_token_named_proj" | ||
project_to_add = gl.projects.create({"name": project_name}) | ||
scope.allowlist.create({"target_project_id": project_to_add.id}) | ||
scope.refresh() | ||
assert any(allowed.name == project_name for allowed in scope.allowlist.list()) | ||
project_to_add.delete() | ||
@pytest.mark.xfail(reason="project job_token_scope api only in 16.*") | ||
def test_remove_project_by_id_from_projects_job_token_scope_allowlist(gl, project): | ||
scope = project.job_token_scope.get() | ||
assert len(scope.allowlist.list()) == 0 | ||
project_to_add = gl.projects.create({"name": "Ci_Cd_token_remove_proj"}) | ||
scope.allowlist.create({"target_project_id": project_to_add.id}) | ||
scope.refresh() | ||
assert len(scope.allowlist.list()) != 0 | ||
scope.allowlist.remove(project_to_add.id) | ||
scope.refresh() | ||
assert len(scope.allowlist.list()) == 0 | ||
project_to_add.delete() |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.