Add git forge integration
This commit is contained in:
2
e2e_tests/.gitignore
vendored
2
e2e_tests/.gitignore
vendored
@@ -1,2 +0,0 @@
|
||||
/venv/
|
||||
/__pycache__/
|
||||
8
e2e_tests/conftest.py
Normal file
8
e2e_tests/conftest.py
Normal file
@@ -0,0 +1,8 @@
|
||||
import os
|
||||
|
||||
|
||||
def pytest_configure(config):
|
||||
os.environ["GIT_AUTHOR_NAME"] = "Example user"
|
||||
os.environ["GIT_AUTHOR_EMAIL"] = "user@example.com"
|
||||
os.environ["GIT_COMMITTER_NAME"] = "Example user"
|
||||
os.environ["GIT_COMMITTER_EMAIL"] = "user@example.com"
|
||||
34
e2e_tests/docker-compose.yml
Normal file
34
e2e_tests/docker-compose.yml
Normal file
@@ -0,0 +1,34 @@
|
||||
version: "3.7"
|
||||
|
||||
services:
|
||||
pytest:
|
||||
build: ./docker
|
||||
volumes:
|
||||
- type: bind
|
||||
source: ./
|
||||
target: /tests
|
||||
read_only: true
|
||||
- type: tmpfs
|
||||
target: /tmp
|
||||
environment:
|
||||
TMPDIR: /tmp
|
||||
depends_on:
|
||||
- rest
|
||||
command:
|
||||
- "true"
|
||||
networks:
|
||||
main:
|
||||
|
||||
rest:
|
||||
build: ./docker-rest/
|
||||
expose:
|
||||
- "5000"
|
||||
ports:
|
||||
- "5000:5000"
|
||||
networks:
|
||||
main:
|
||||
aliases:
|
||||
- alternate-rest
|
||||
|
||||
networks:
|
||||
main:
|
||||
19
e2e_tests/docker-rest/Dockerfile
Normal file
19
e2e_tests/docker-rest/Dockerfile
Normal file
@@ -0,0 +1,19 @@
|
||||
FROM docker.io/debian:11.3
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ENV FLASK_APP=app.py
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y \
|
||||
dumb-init \
|
||||
python3-flask \
|
||||
python3-jinja2 \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
EXPOSE 5000
|
||||
|
||||
COPY flask .
|
||||
|
||||
CMD ["/usr/bin/dumb-init", "--", "flask", "run", "--port", "5000", "--host", "0.0.0.0"]
|
||||
7
e2e_tests/docker-rest/flask/app.py
Normal file
7
e2e_tests/docker-rest/flask/app.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from flask import Flask
|
||||
|
||||
app = Flask(__name__)
|
||||
app.url_map.strict_slashes = False
|
||||
|
||||
import github
|
||||
import gitlab
|
||||
103
e2e_tests/docker-rest/flask/github.py
Normal file
103
e2e_tests/docker-rest/flask/github.py
Normal file
@@ -0,0 +1,103 @@
|
||||
import os.path
|
||||
|
||||
from app import app
|
||||
|
||||
from flask import Flask, request, abort, jsonify, make_response
|
||||
|
||||
import jinja2
|
||||
|
||||
|
||||
def check_headers():
|
||||
if request.headers.get("accept") != "application/vnd.github.v3+json":
|
||||
app.logger.error("Invalid accept header")
|
||||
abort(500)
|
||||
auth_header = request.headers.get("authorization")
|
||||
if auth_header != "token authtoken":
|
||||
app.logger.error("Invalid authorization header: %s", auth_header)
|
||||
abort(
|
||||
make_response(
|
||||
jsonify(
|
||||
{
|
||||
"message": "Bad credentials",
|
||||
"documentation_url": "https://docs.example.com/rest",
|
||||
}
|
||||
),
|
||||
401,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def add_pagination(response, page, last_page):
|
||||
host = request.headers["host"]
|
||||
link_header = ""
|
||||
|
||||
def args(page):
|
||||
args = request.args.copy()
|
||||
args["page"] = page
|
||||
return "&".join([f"{k}={v}" for k, v in args.items()])
|
||||
|
||||
if page < last_page:
|
||||
link_header += (
|
||||
f'<{request.scheme}://{host}{request.path}?{args(page+1)}>; rel="next", '
|
||||
)
|
||||
link_header += (
|
||||
f'<{request.scheme}://{host}{request.path}?{args(last_page)}>; rel="last"'
|
||||
)
|
||||
response.headers["link"] = link_header
|
||||
|
||||
|
||||
def read_project_files(namespaces=[]):
|
||||
last_page = 4
|
||||
page = username = int(request.args.get("page", "1"))
|
||||
response_file = f"./github_api_page_{page}.json.j2"
|
||||
if not os.path.exists(response_file):
|
||||
return jsonify([])
|
||||
|
||||
response = make_response(
|
||||
jinja2.Template(open(response_file).read()).render(
|
||||
namespace=namespaces[page - 1]
|
||||
)
|
||||
)
|
||||
add_pagination(response, page, last_page)
|
||||
response.headers["content-type"] = "application/json"
|
||||
return response
|
||||
|
||||
|
||||
def single_namespaced_projects(namespace):
|
||||
return read_project_files([namespace] * 4)
|
||||
|
||||
|
||||
def mixed_projects(namespaces):
|
||||
return read_project_files(namespaces)
|
||||
|
||||
|
||||
@app.route("/github/users/<string:user>/repos/")
|
||||
def github_user_repos(user):
|
||||
check_headers()
|
||||
if user == "myuser1":
|
||||
return single_namespaced_projects("myuser1")
|
||||
return jsonify([])
|
||||
|
||||
|
||||
@app.route("/github/orgs/<string:group>/repos/")
|
||||
def github_group_repos(group):
|
||||
check_headers()
|
||||
if not (request.args.get("type") == "all"):
|
||||
abort(500, "wrong arguments")
|
||||
if group == "mygroup1":
|
||||
return single_namespaced_projects("mygroup1")
|
||||
return jsonify([])
|
||||
|
||||
|
||||
@app.route("/github/user/repos/")
|
||||
def github_own_repos():
|
||||
check_headers()
|
||||
return mixed_projects(["myuser1", "myuser2", "mygroup1", "mygroup2"])
|
||||
|
||||
|
||||
@app.route("/github/user/")
|
||||
def github_user():
|
||||
check_headers()
|
||||
response = make_response(open("./github_api_user.json").read())
|
||||
response.headers["content-type"] = "application/json"
|
||||
return response
|
||||
228
e2e_tests/docker-rest/flask/github_api_page_1.json.j2
Normal file
228
e2e_tests/docker-rest/flask/github_api_page_1.json.j2
Normal file
@@ -0,0 +1,228 @@
|
||||
[
|
||||
{
|
||||
"id": 1,
|
||||
"node_id": "MDEwOlJlcG9zaXRvcnk0OTIzNDY2Ng==",
|
||||
"name": "myproject1",
|
||||
"full_name": "{{ namespace }}/myproject1",
|
||||
"private": true,
|
||||
"owner": {
|
||||
"login": "someuser",
|
||||
"id": 1,
|
||||
"node_id": "MDQ6VXNlcjM3NDg2OTY=",
|
||||
"avatar_url": "https://example.com/u/3748696?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.example.com/users/{{ namespace }}",
|
||||
"html_url": "https://example.com/{{ namespace }}",
|
||||
"followers_url": "https://api.example.com/users/{{ namespace }}/followers",
|
||||
"following_url": "https://api.example.com/users/{{ namespace }}/following{/other_user}",
|
||||
"gists_url": "https://api.example.com/users/{{ namespace }}/gists{/gist_id}",
|
||||
"starred_url": "https://api.example.com/users/{{ namespace }}/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.example.com/users/{{ namespace }}/subscriptions",
|
||||
"organizations_url": "https://api.example.com/users/{{ namespace }}/orgs",
|
||||
"repos_url": "https://api.example.com/users/{{ namespace }}/repos",
|
||||
"events_url": "https://api.example.com/users/{{ namespace }}/events{/privacy}",
|
||||
"received_events_url": "https://api.example.com/users/{{ namespace }}/received_events",
|
||||
"type": "User",
|
||||
"site_admin": false
|
||||
},
|
||||
"html_url": "https://example.com/{{ namespace }}/myproject1",
|
||||
"description": "Shell script for automatically building ACI containers from scratch using acbuild.",
|
||||
"fork": false,
|
||||
"url": "https://api.example.com/repos/{{ namespace }}/myproject1",
|
||||
"forks_url": "https://api.example.com/repos/{{ namespace }}/myproject1/forks",
|
||||
"keys_url": "https://api.example.com/repos/{{ namespace }}/myproject1/keys{/key_id}",
|
||||
"collaborators_url": "https://api.example.com/repos/{{ namespace }}/myproject1/collaborators{/collaborator}",
|
||||
"teams_url": "https://api.example.com/repos/{{ namespace }}/myproject1/teams",
|
||||
"hooks_url": "https://api.example.com/repos/{{ namespace }}/myproject1/hooks",
|
||||
"issue_events_url": "https://api.example.com/repos/{{ namespace }}/myproject1/issues/events{/number}",
|
||||
"events_url": "https://api.example.com/repos/{{ namespace }}/myproject1/events",
|
||||
"assignees_url": "https://api.example.com/repos/{{ namespace }}/myproject1/assignees{/user}",
|
||||
"branches_url": "https://api.example.com/repos/{{ namespace }}/myproject1/branches{/branch}",
|
||||
"tags_url": "https://api.example.com/repos/{{ namespace }}/myproject1/tags",
|
||||
"blobs_url": "https://api.example.com/repos/{{ namespace }}/myproject1/git/blobs{/sha}",
|
||||
"git_tags_url": "https://api.example.com/repos/{{ namespace }}/myproject1/git/tags{/sha}",
|
||||
"git_refs_url": "https://api.example.com/repos/{{ namespace }}/myproject1/git/refs{/sha}",
|
||||
"trees_url": "https://api.example.com/repos/{{ namespace }}/myproject1/git/trees{/sha}",
|
||||
"statuses_url": "https://api.example.com/repos/{{ namespace }}/myproject1/statuses/{sha}",
|
||||
"languages_url": "https://api.example.com/repos/{{ namespace }}/myproject1/languages",
|
||||
"stargazers_url": "https://api.example.com/repos/{{ namespace }}/myproject1/stargazers",
|
||||
"contributors_url": "https://api.example.com/repos/{{ namespace }}/myproject1/contributors",
|
||||
"subscribers_url": "https://api.example.com/repos/{{ namespace }}/myproject1/subscribers",
|
||||
"subscription_url": "https://api.example.com/repos/{{ namespace }}/myproject1/subscription",
|
||||
"commits_url": "https://api.example.com/repos/{{ namespace }}/myproject1/commits{/sha}",
|
||||
"git_commits_url": "https://api.example.com/repos/{{ namespace }}/myproject1/git/commits{/sha}",
|
||||
"comments_url": "https://api.example.com/repos/{{ namespace }}/myproject1/comments{/number}",
|
||||
"issue_comment_url": "https://api.example.com/repos/{{ namespace }}/myproject1/issues/comments{/number}",
|
||||
"contents_url": "https://api.example.com/repos/{{ namespace }}/myproject1/contents/{+path}",
|
||||
"compare_url": "https://api.example.com/repos/{{ namespace }}/myproject1/compare/{base}...{head}",
|
||||
"merges_url": "https://api.example.com/repos/{{ namespace }}/myproject1/merges",
|
||||
"archive_url": "https://api.example.com/repos/{{ namespace }}/myproject1/{archive_format}{/ref}",
|
||||
"downloads_url": "https://api.example.com/repos/{{ namespace }}/myproject1/downloads",
|
||||
"issues_url": "https://api.example.com/repos/{{ namespace }}/myproject1/issues{/number}",
|
||||
"pulls_url": "https://api.example.com/repos/{{ namespace }}/myproject1/pulls{/number}",
|
||||
"milestones_url": "https://api.example.com/repos/{{ namespace }}/myproject1/milestones{/number}",
|
||||
"notifications_url": "https://api.example.com/repos/{{ namespace }}/myproject1/notifications{?since,all,participating}",
|
||||
"labels_url": "https://api.example.com/repos/{{ namespace }}/myproject1/labels{/name}",
|
||||
"releases_url": "https://api.example.com/repos/{{ namespace }}/myproject1/releases{/id}",
|
||||
"deployments_url": "https://api.example.com/repos/{{ namespace }}/myproject1/deployments",
|
||||
"created_at": "2016-01-07T22:27:54Z",
|
||||
"updated_at": "2021-11-20T16:15:37Z",
|
||||
"pushed_at": "2021-11-20T16:15:34Z",
|
||||
"git_url": "git://example.com/{{ namespace }}/myproject1.git",
|
||||
"ssh_url": "ssh://git@example.com/{{ namespace }}/myproject1.git",
|
||||
"clone_url": "https://example.com/{{ namespace }}/myproject1.git",
|
||||
"svn_url": "https://example.com/{{ namespace }}/myproject1",
|
||||
"homepage": null,
|
||||
"size": 12,
|
||||
"stargazers_count": 0,
|
||||
"watchers_count": 0,
|
||||
"language": "Shell",
|
||||
"has_issues": true,
|
||||
"has_projects": true,
|
||||
"has_downloads": true,
|
||||
"has_wiki": true,
|
||||
"has_pages": false,
|
||||
"forks_count": 0,
|
||||
"mirror_url": null,
|
||||
"archived": false,
|
||||
"disabled": false,
|
||||
"open_issues_count": 0,
|
||||
"license": {
|
||||
"key": "apache-2.0",
|
||||
"name": "Apache License 2.0",
|
||||
"spdx_id": "Apache-2.0",
|
||||
"url": "https://api.example.com/licenses/apache-2.0",
|
||||
"node_id": "MDc6TGljZW5zZTI="
|
||||
},
|
||||
"allow_forking": true,
|
||||
"is_template": false,
|
||||
"topics": [
|
||||
|
||||
],
|
||||
"visibility": "public",
|
||||
"forks": 0,
|
||||
"open_issues": 0,
|
||||
"watchers": 0,
|
||||
"default_branch": "master",
|
||||
"permissions": {
|
||||
"admin": true,
|
||||
"maintain": true,
|
||||
"push": true,
|
||||
"triage": true,
|
||||
"pull": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"node_id": "MDEwOlJlcG9zaXRvcnk0OTIzNDY2Ng==",
|
||||
"name": "myproject2",
|
||||
"full_name": "{{ namespace }}/myproject2",
|
||||
"private": false,
|
||||
"owner": {
|
||||
"login": "someuser",
|
||||
"id": 1,
|
||||
"node_id": "MDQ6VXNlcjM3NDg2OTY=",
|
||||
"avatar_url": "https://example.com/u/3748696?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.example.com/users/{{ namespace }}",
|
||||
"html_url": "https://example.com/{{ namespace }}",
|
||||
"followers_url": "https://api.example.com/users/{{ namespace }}/followers",
|
||||
"following_url": "https://api.example.com/users/{{ namespace }}/following{/other_user}",
|
||||
"gists_url": "https://api.example.com/users/{{ namespace }}/gists{/gist_id}",
|
||||
"starred_url": "https://api.example.com/users/{{ namespace }}/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.example.com/users/{{ namespace }}/subscriptions",
|
||||
"organizations_url": "https://api.example.com/users/{{ namespace }}/orgs",
|
||||
"repos_url": "https://api.example.com/users/{{ namespace }}/repos",
|
||||
"events_url": "https://api.example.com/users/{{ namespace }}/events{/privacy}",
|
||||
"received_events_url": "https://api.example.com/users/{{ namespace }}/received_events",
|
||||
"type": "User",
|
||||
"site_admin": false
|
||||
},
|
||||
"html_url": "https://example.com/{{ namespace }}/myproject2",
|
||||
"description": "Shell script for automatically building ACI containers from scratch using acbuild.",
|
||||
"fork": false,
|
||||
"url": "https://api.example.com/repos/{{ namespace }}/myproject2",
|
||||
"forks_url": "https://api.example.com/repos/{{ namespace }}/myproject2/forks",
|
||||
"keys_url": "https://api.example.com/repos/{{ namespace }}/myproject2/keys{/key_id}",
|
||||
"collaborators_url": "https://api.example.com/repos/{{ namespace }}/myproject2/collaborators{/collaborator}",
|
||||
"teams_url": "https://api.example.com/repos/{{ namespace }}/myproject2/teams",
|
||||
"hooks_url": "https://api.example.com/repos/{{ namespace }}/myproject2/hooks",
|
||||
"issue_events_url": "https://api.example.com/repos/{{ namespace }}/myproject2/issues/events{/number}",
|
||||
"events_url": "https://api.example.com/repos/{{ namespace }}/myproject2/events",
|
||||
"assignees_url": "https://api.example.com/repos/{{ namespace }}/myproject2/assignees{/user}",
|
||||
"branches_url": "https://api.example.com/repos/{{ namespace }}/myproject2/branches{/branch}",
|
||||
"tags_url": "https://api.example.com/repos/{{ namespace }}/myproject2/tags",
|
||||
"blobs_url": "https://api.example.com/repos/{{ namespace }}/myproject2/git/blobs{/sha}",
|
||||
"git_tags_url": "https://api.example.com/repos/{{ namespace }}/myproject2/git/tags{/sha}",
|
||||
"git_refs_url": "https://api.example.com/repos/{{ namespace }}/myproject2/git/refs{/sha}",
|
||||
"trees_url": "https://api.example.com/repos/{{ namespace }}/myproject2/git/trees{/sha}",
|
||||
"statuses_url": "https://api.example.com/repos/{{ namespace }}/myproject2/statuses/{sha}",
|
||||
"languages_url": "https://api.example.com/repos/{{ namespace }}/myproject2/languages",
|
||||
"stargazers_url": "https://api.example.com/repos/{{ namespace }}/myproject2/stargazers",
|
||||
"contributors_url": "https://api.example.com/repos/{{ namespace }}/myproject2/contributors",
|
||||
"subscribers_url": "https://api.example.com/repos/{{ namespace }}/myproject2/subscribers",
|
||||
"subscription_url": "https://api.example.com/repos/{{ namespace }}/myproject2/subscription",
|
||||
"commits_url": "https://api.example.com/repos/{{ namespace }}/myproject2/commits{/sha}",
|
||||
"git_commits_url": "https://api.example.com/repos/{{ namespace }}/myproject2/git/commits{/sha}",
|
||||
"comments_url": "https://api.example.com/repos/{{ namespace }}/myproject2/comments{/number}",
|
||||
"issue_comment_url": "https://api.example.com/repos/{{ namespace }}/myproject2/issues/comments{/number}",
|
||||
"contents_url": "https://api.example.com/repos/{{ namespace }}/myproject2/contents/{+path}",
|
||||
"compare_url": "https://api.example.com/repos/{{ namespace }}/myproject2/compare/{base}...{head}",
|
||||
"merges_url": "https://api.example.com/repos/{{ namespace }}/myproject2/merges",
|
||||
"archive_url": "https://api.example.com/repos/{{ namespace }}/myproject2/{archive_format}{/ref}",
|
||||
"downloads_url": "https://api.example.com/repos/{{ namespace }}/myproject2/downloads",
|
||||
"issues_url": "https://api.example.com/repos/{{ namespace }}/myproject2/issues{/number}",
|
||||
"pulls_url": "https://api.example.com/repos/{{ namespace }}/myproject2/pulls{/number}",
|
||||
"milestones_url": "https://api.example.com/repos/{{ namespace }}/myproject2/milestones{/number}",
|
||||
"notifications_url": "https://api.example.com/repos/{{ namespace }}/myproject2/notifications{?since,all,participating}",
|
||||
"labels_url": "https://api.example.com/repos/{{ namespace }}/myproject2/labels{/name}",
|
||||
"releases_url": "https://api.example.com/repos/{{ namespace }}/myproject2/releases{/id}",
|
||||
"deployments_url": "https://api.example.com/repos/{{ namespace }}/myproject2/deployments",
|
||||
"created_at": "2016-01-07T22:27:54Z",
|
||||
"updated_at": "2021-11-20T16:15:37Z",
|
||||
"pushed_at": "2021-11-20T16:15:34Z",
|
||||
"git_url": "git://example.com/{{ namespace }}/myproject2.git",
|
||||
"ssh_url": "ssh://git@example.com/{{ namespace }}/myproject2.git",
|
||||
"clone_url": "https://example.com/{{ namespace }}/myproject2.git",
|
||||
"svn_url": "https://example.com/{{ namespace }}/myproject2",
|
||||
"homepage": null,
|
||||
"size": 12,
|
||||
"stargazers_count": 0,
|
||||
"watchers_count": 0,
|
||||
"language": "Shell",
|
||||
"has_issues": true,
|
||||
"has_projects": true,
|
||||
"has_downloads": true,
|
||||
"has_wiki": true,
|
||||
"has_pages": false,
|
||||
"forks_count": 0,
|
||||
"mirror_url": null,
|
||||
"archived": false,
|
||||
"disabled": false,
|
||||
"open_issues_count": 0,
|
||||
"license": {
|
||||
"key": "apache-2.0",
|
||||
"name": "Apache License 2.0",
|
||||
"spdx_id": "Apache-2.0",
|
||||
"url": "https://api.example.com/licenses/apache-2.0",
|
||||
"node_id": "MDc6TGljZW5zZTI="
|
||||
},
|
||||
"allow_forking": true,
|
||||
"is_template": false,
|
||||
"topics": [
|
||||
|
||||
],
|
||||
"visibility": "public",
|
||||
"forks": 0,
|
||||
"open_issues": 0,
|
||||
"watchers": 0,
|
||||
"default_branch": "master",
|
||||
"permissions": {
|
||||
"admin": true,
|
||||
"maintain": true,
|
||||
"push": true,
|
||||
"triage": true,
|
||||
"pull": true
|
||||
}
|
||||
}
|
||||
]
|
||||
115
e2e_tests/docker-rest/flask/github_api_page_2.json.j2
Normal file
115
e2e_tests/docker-rest/flask/github_api_page_2.json.j2
Normal file
@@ -0,0 +1,115 @@
|
||||
[
|
||||
{
|
||||
"id": 3,
|
||||
"node_id": "MDEwOlJlcG9zaXRvcnk0OTIzNDY2Ng==",
|
||||
"name": "myproject3",
|
||||
"full_name": "{{ namespace }}/myproject3",
|
||||
"private": false,
|
||||
"owner": {
|
||||
"login": "someuser",
|
||||
"id": 1,
|
||||
"node_id": "MDQ6VXNlcjM3NDg2OTY=",
|
||||
"avatar_url": "https://example.com/u/3748696?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.example.com/users/{{ namespace }}",
|
||||
"html_url": "https://example.com/{{ namespace }}",
|
||||
"followers_url": "https://api.example.com/users/{{ namespace }}/followers",
|
||||
"following_url": "https://api.example.com/users/{{ namespace }}/following{/other_user}",
|
||||
"gists_url": "https://api.example.com/users/{{ namespace }}/gists{/gist_id}",
|
||||
"starred_url": "https://api.example.com/users/{{ namespace }}/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.example.com/users/{{ namespace }}/subscriptions",
|
||||
"organizations_url": "https://api.example.com/users/{{ namespace }}/orgs",
|
||||
"repos_url": "https://api.example.com/users/{{ namespace }}/repos",
|
||||
"events_url": "https://api.example.com/users/{{ namespace }}/events{/privacy}",
|
||||
"received_events_url": "https://api.example.com/users/{{ namespace }}/received_events",
|
||||
"type": "User",
|
||||
"site_admin": false
|
||||
},
|
||||
"html_url": "https://example.com/{{ namespace }}/myproject3",
|
||||
"description": "Shell script for automatically building ACI containers from scratch using acbuild.",
|
||||
"fork": false,
|
||||
"url": "https://api.example.com/repos/{{ namespace }}/myproject3",
|
||||
"forks_url": "https://api.example.com/repos/{{ namespace }}/myproject3/forks",
|
||||
"keys_url": "https://api.example.com/repos/{{ namespace }}/myproject3/keys{/key_id}",
|
||||
"collaborators_url": "https://api.example.com/repos/{{ namespace }}/myproject3/collaborators{/collaborator}",
|
||||
"teams_url": "https://api.example.com/repos/{{ namespace }}/myproject3/teams",
|
||||
"hooks_url": "https://api.example.com/repos/{{ namespace }}/myproject3/hooks",
|
||||
"issue_events_url": "https://api.example.com/repos/{{ namespace }}/myproject3/issues/events{/number}",
|
||||
"events_url": "https://api.example.com/repos/{{ namespace }}/myproject3/events",
|
||||
"assignees_url": "https://api.example.com/repos/{{ namespace }}/myproject3/assignees{/user}",
|
||||
"branches_url": "https://api.example.com/repos/{{ namespace }}/myproject3/branches{/branch}",
|
||||
"tags_url": "https://api.example.com/repos/{{ namespace }}/myproject3/tags",
|
||||
"blobs_url": "https://api.example.com/repos/{{ namespace }}/myproject3/git/blobs{/sha}",
|
||||
"git_tags_url": "https://api.example.com/repos/{{ namespace }}/myproject3/git/tags{/sha}",
|
||||
"git_refs_url": "https://api.example.com/repos/{{ namespace }}/myproject3/git/refs{/sha}",
|
||||
"trees_url": "https://api.example.com/repos/{{ namespace }}/myproject3/git/trees{/sha}",
|
||||
"statuses_url": "https://api.example.com/repos/{{ namespace }}/myproject3/statuses/{sha}",
|
||||
"languages_url": "https://api.example.com/repos/{{ namespace }}/myproject3/languages",
|
||||
"stargazers_url": "https://api.example.com/repos/{{ namespace }}/myproject3/stargazers",
|
||||
"contributors_url": "https://api.example.com/repos/{{ namespace }}/myproject3/contributors",
|
||||
"subscribers_url": "https://api.example.com/repos/{{ namespace }}/myproject3/subscribers",
|
||||
"subscription_url": "https://api.example.com/repos/{{ namespace }}/myproject3/subscription",
|
||||
"commits_url": "https://api.example.com/repos/{{ namespace }}/myproject3/commits{/sha}",
|
||||
"git_commits_url": "https://api.example.com/repos/{{ namespace }}/myproject3/git/commits{/sha}",
|
||||
"comments_url": "https://api.example.com/repos/{{ namespace }}/myproject3/comments{/number}",
|
||||
"issue_comment_url": "https://api.example.com/repos/{{ namespace }}/myproject3/issues/comments{/number}",
|
||||
"contents_url": "https://api.example.com/repos/{{ namespace }}/myproject3/contents/{+path}",
|
||||
"compare_url": "https://api.example.com/repos/{{ namespace }}/myproject3/compare/{base}...{head}",
|
||||
"merges_url": "https://api.example.com/repos/{{ namespace }}/myproject3/merges",
|
||||
"archive_url": "https://api.example.com/repos/{{ namespace }}/myproject3/{archive_format}{/ref}",
|
||||
"downloads_url": "https://api.example.com/repos/{{ namespace }}/myproject3/downloads",
|
||||
"issues_url": "https://api.example.com/repos/{{ namespace }}/myproject3/issues{/number}",
|
||||
"pulls_url": "https://api.example.com/repos/{{ namespace }}/myproject3/pulls{/number}",
|
||||
"milestones_url": "https://api.example.com/repos/{{ namespace }}/myproject3/milestones{/number}",
|
||||
"notifications_url": "https://api.example.com/repos/{{ namespace }}/myproject3/notifications{?since,all,participating}",
|
||||
"labels_url": "https://api.example.com/repos/{{ namespace }}/myproject3/labels{/name}",
|
||||
"releases_url": "https://api.example.com/repos/{{ namespace }}/myproject3/releases{/id}",
|
||||
"deployments_url": "https://api.example.com/repos/{{ namespace }}/myproject3/deployments",
|
||||
"created_at": "2016-01-07T22:27:54Z",
|
||||
"updated_at": "2021-11-20T16:15:37Z",
|
||||
"pushed_at": "2021-11-20T16:15:34Z",
|
||||
"git_url": "git://example.com/{{ namespace }}/myproject3.git",
|
||||
"ssh_url": "ssh://git@example.com/{{ namespace }}/myproject3.git",
|
||||
"clone_url": "https://example.com/{{ namespace }}/myproject3.git",
|
||||
"svn_url": "https://example.com/{{ namespace }}/myproject3",
|
||||
"homepage": null,
|
||||
"size": 12,
|
||||
"stargazers_count": 0,
|
||||
"watchers_count": 0,
|
||||
"language": "Shell",
|
||||
"has_issues": true,
|
||||
"has_projects": true,
|
||||
"has_downloads": true,
|
||||
"has_wiki": true,
|
||||
"has_pages": false,
|
||||
"forks_count": 0,
|
||||
"mirror_url": null,
|
||||
"archived": false,
|
||||
"disabled": false,
|
||||
"open_issues_count": 0,
|
||||
"license": {
|
||||
"key": "apache-2.0",
|
||||
"name": "Apache License 2.0",
|
||||
"spdx_id": "Apache-2.0",
|
||||
"url": "https://api.example.com/licenses/apache-2.0",
|
||||
"node_id": "MDc6TGljZW5zZTI="
|
||||
},
|
||||
"allow_forking": true,
|
||||
"is_template": false,
|
||||
"topics": [
|
||||
|
||||
],
|
||||
"visibility": "public",
|
||||
"forks": 0,
|
||||
"open_issues": 0,
|
||||
"watchers": 0,
|
||||
"default_branch": "master",
|
||||
"permissions": {
|
||||
"admin": true,
|
||||
"maintain": true,
|
||||
"push": true,
|
||||
"triage": true,
|
||||
"pull": true
|
||||
}
|
||||
}
|
||||
]
|
||||
115
e2e_tests/docker-rest/flask/github_api_page_3.json.j2
Normal file
115
e2e_tests/docker-rest/flask/github_api_page_3.json.j2
Normal file
@@ -0,0 +1,115 @@
|
||||
[
|
||||
{
|
||||
"id": 3,
|
||||
"node_id": "MDEwOlJlcG9zaXRvcnk0OTIzNDY2Ng==",
|
||||
"name": "myproject4",
|
||||
"full_name": "{{ namespace }}/myproject4",
|
||||
"private": false,
|
||||
"owner": {
|
||||
"login": "someuser",
|
||||
"id": 1,
|
||||
"node_id": "MDQ6VXNlcjM3NDg2OTY=",
|
||||
"avatar_url": "https://example.com/u/3748696?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.example.com/users/{{ namespace }}",
|
||||
"html_url": "https://example.com/{{ namespace }}",
|
||||
"followers_url": "https://api.example.com/users/{{ namespace }}/followers",
|
||||
"following_url": "https://api.example.com/users/{{ namespace }}/following{/other_user}",
|
||||
"gists_url": "https://api.example.com/users/{{ namespace }}/gists{/gist_id}",
|
||||
"starred_url": "https://api.example.com/users/{{ namespace }}/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.example.com/users/{{ namespace }}/subscriptions",
|
||||
"organizations_url": "https://api.example.com/users/{{ namespace }}/orgs",
|
||||
"repos_url": "https://api.example.com/users/{{ namespace }}/repos",
|
||||
"events_url": "https://api.example.com/users/{{ namespace }}/events{/privacy}",
|
||||
"received_events_url": "https://api.example.com/users/{{ namespace }}/received_events",
|
||||
"type": "User",
|
||||
"site_admin": false
|
||||
},
|
||||
"html_url": "https://example.com/{{ namespace }}/myproject4",
|
||||
"description": "Shell script for automatically building ACI containers from scratch using acbuild.",
|
||||
"fork": false,
|
||||
"url": "https://api.example.com/repos/{{ namespace }}/myproject4",
|
||||
"forks_url": "https://api.example.com/repos/{{ namespace }}/myproject4/forks",
|
||||
"keys_url": "https://api.example.com/repos/{{ namespace }}/myproject4/keys{/key_id}",
|
||||
"collaborators_url": "https://api.example.com/repos/{{ namespace }}/myproject4/collaborators{/collaborator}",
|
||||
"teams_url": "https://api.example.com/repos/{{ namespace }}/myproject4/teams",
|
||||
"hooks_url": "https://api.example.com/repos/{{ namespace }}/myproject4/hooks",
|
||||
"issue_events_url": "https://api.example.com/repos/{{ namespace }}/myproject4/issues/events{/number}",
|
||||
"events_url": "https://api.example.com/repos/{{ namespace }}/myproject4/events",
|
||||
"assignees_url": "https://api.example.com/repos/{{ namespace }}/myproject4/assignees{/user}",
|
||||
"branches_url": "https://api.example.com/repos/{{ namespace }}/myproject4/branches{/branch}",
|
||||
"tags_url": "https://api.example.com/repos/{{ namespace }}/myproject4/tags",
|
||||
"blobs_url": "https://api.example.com/repos/{{ namespace }}/myproject4/git/blobs{/sha}",
|
||||
"git_tags_url": "https://api.example.com/repos/{{ namespace }}/myproject4/git/tags{/sha}",
|
||||
"git_refs_url": "https://api.example.com/repos/{{ namespace }}/myproject4/git/refs{/sha}",
|
||||
"trees_url": "https://api.example.com/repos/{{ namespace }}/myproject4/git/trees{/sha}",
|
||||
"statuses_url": "https://api.example.com/repos/{{ namespace }}/myproject4/statuses/{sha}",
|
||||
"languages_url": "https://api.example.com/repos/{{ namespace }}/myproject4/languages",
|
||||
"stargazers_url": "https://api.example.com/repos/{{ namespace }}/myproject4/stargazers",
|
||||
"contributors_url": "https://api.example.com/repos/{{ namespace }}/myproject4/contributors",
|
||||
"subscribers_url": "https://api.example.com/repos/{{ namespace }}/myproject4/subscribers",
|
||||
"subscription_url": "https://api.example.com/repos/{{ namespace }}/myproject4/subscription",
|
||||
"commits_url": "https://api.example.com/repos/{{ namespace }}/myproject4/commits{/sha}",
|
||||
"git_commits_url": "https://api.example.com/repos/{{ namespace }}/myproject4/git/commits{/sha}",
|
||||
"comments_url": "https://api.example.com/repos/{{ namespace }}/myproject4/comments{/number}",
|
||||
"issue_comment_url": "https://api.example.com/repos/{{ namespace }}/myproject4/issues/comments{/number}",
|
||||
"contents_url": "https://api.example.com/repos/{{ namespace }}/myproject4/contents/{+path}",
|
||||
"compare_url": "https://api.example.com/repos/{{ namespace }}/myproject4/compare/{base}...{head}",
|
||||
"merges_url": "https://api.example.com/repos/{{ namespace }}/myproject4/merges",
|
||||
"archive_url": "https://api.example.com/repos/{{ namespace }}/myproject4/{archive_format}{/ref}",
|
||||
"downloads_url": "https://api.example.com/repos/{{ namespace }}/myproject4/downloads",
|
||||
"issues_url": "https://api.example.com/repos/{{ namespace }}/myproject4/issues{/number}",
|
||||
"pulls_url": "https://api.example.com/repos/{{ namespace }}/myproject4/pulls{/number}",
|
||||
"milestones_url": "https://api.example.com/repos/{{ namespace }}/myproject4/milestones{/number}",
|
||||
"notifications_url": "https://api.example.com/repos/{{ namespace }}/myproject4/notifications{?since,all,participating}",
|
||||
"labels_url": "https://api.example.com/repos/{{ namespace }}/myproject4/labels{/name}",
|
||||
"releases_url": "https://api.example.com/repos/{{ namespace }}/myproject4/releases{/id}",
|
||||
"deployments_url": "https://api.example.com/repos/{{ namespace }}/myproject4/deployments",
|
||||
"created_at": "2016-01-07T22:27:54Z",
|
||||
"updated_at": "2021-11-20T16:15:37Z",
|
||||
"pushed_at": "2021-11-20T16:15:34Z",
|
||||
"git_url": "git://example.com/{{ namespace }}/myproject4.git",
|
||||
"ssh_url": "ssh://git@example.com/{{ namespace }}/myproject4.git",
|
||||
"clone_url": "https://example.com/{{ namespace }}/myproject4.git",
|
||||
"svn_url": "https://example.com/{{ namespace }}/myproject4",
|
||||
"homepage": null,
|
||||
"size": 12,
|
||||
"stargazers_count": 0,
|
||||
"watchers_count": 0,
|
||||
"language": "Shell",
|
||||
"has_issues": true,
|
||||
"has_projects": true,
|
||||
"has_downloads": true,
|
||||
"has_wiki": true,
|
||||
"has_pages": false,
|
||||
"forks_count": 0,
|
||||
"mirror_url": null,
|
||||
"archived": false,
|
||||
"disabled": false,
|
||||
"open_issues_count": 0,
|
||||
"license": {
|
||||
"key": "apache-2.0",
|
||||
"name": "Apache License 2.0",
|
||||
"spdx_id": "Apache-2.0",
|
||||
"url": "https://api.example.com/licenses/apache-2.0",
|
||||
"node_id": "MDc6TGljZW5zZTI="
|
||||
},
|
||||
"allow_forking": true,
|
||||
"is_template": false,
|
||||
"topics": [
|
||||
|
||||
],
|
||||
"visibility": "public",
|
||||
"forks": 0,
|
||||
"open_issues": 0,
|
||||
"watchers": 0,
|
||||
"default_branch": "master",
|
||||
"permissions": {
|
||||
"admin": true,
|
||||
"maintain": true,
|
||||
"push": true,
|
||||
"triage": true,
|
||||
"pull": true
|
||||
}
|
||||
}
|
||||
]
|
||||
115
e2e_tests/docker-rest/flask/github_api_page_4.json.j2
Normal file
115
e2e_tests/docker-rest/flask/github_api_page_4.json.j2
Normal file
@@ -0,0 +1,115 @@
|
||||
[
|
||||
{
|
||||
"id": 3,
|
||||
"node_id": "MDEwOlJlcG9zaXRvcnk0OTIzNDY2Ng==",
|
||||
"name": "myproject5",
|
||||
"full_name": "{{ namespace }}/myproject5",
|
||||
"private": false,
|
||||
"owner": {
|
||||
"login": "someuser",
|
||||
"id": 1,
|
||||
"node_id": "MDQ6VXNlcjM3NDg2OTY=",
|
||||
"avatar_url": "https://example.com/u/3748696?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.example.com/users/{{ namespace }}",
|
||||
"html_url": "https://example.com/{{ namespace }}",
|
||||
"followers_url": "https://api.example.com/users/{{ namespace }}/followers",
|
||||
"following_url": "https://api.example.com/users/{{ namespace }}/following{/other_user}",
|
||||
"gists_url": "https://api.example.com/users/{{ namespace }}/gists{/gist_id}",
|
||||
"starred_url": "https://api.example.com/users/{{ namespace }}/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.example.com/users/{{ namespace }}/subscriptions",
|
||||
"organizations_url": "https://api.example.com/users/{{ namespace }}/orgs",
|
||||
"repos_url": "https://api.example.com/users/{{ namespace }}/repos",
|
||||
"events_url": "https://api.example.com/users/{{ namespace }}/events{/privacy}",
|
||||
"received_events_url": "https://api.example.com/users/{{ namespace }}/received_events",
|
||||
"type": "User",
|
||||
"site_admin": false
|
||||
},
|
||||
"html_url": "https://example.com/{{ namespace }}/myproject5",
|
||||
"description": "Shell script for automatically building ACI containers from scratch using acbuild.",
|
||||
"fork": false,
|
||||
"url": "https://api.example.com/repos/{{ namespace }}/myproject5",
|
||||
"forks_url": "https://api.example.com/repos/{{ namespace }}/myproject5/forks",
|
||||
"keys_url": "https://api.example.com/repos/{{ namespace }}/myproject5/keys{/key_id}",
|
||||
"collaborators_url": "https://api.example.com/repos/{{ namespace }}/myproject5/collaborators{/collaborator}",
|
||||
"teams_url": "https://api.example.com/repos/{{ namespace }}/myproject5/teams",
|
||||
"hooks_url": "https://api.example.com/repos/{{ namespace }}/myproject5/hooks",
|
||||
"issue_events_url": "https://api.example.com/repos/{{ namespace }}/myproject5/issues/events{/number}",
|
||||
"events_url": "https://api.example.com/repos/{{ namespace }}/myproject5/events",
|
||||
"assignees_url": "https://api.example.com/repos/{{ namespace }}/myproject5/assignees{/user}",
|
||||
"branches_url": "https://api.example.com/repos/{{ namespace }}/myproject5/branches{/branch}",
|
||||
"tags_url": "https://api.example.com/repos/{{ namespace }}/myproject5/tags",
|
||||
"blobs_url": "https://api.example.com/repos/{{ namespace }}/myproject5/git/blobs{/sha}",
|
||||
"git_tags_url": "https://api.example.com/repos/{{ namespace }}/myproject5/git/tags{/sha}",
|
||||
"git_refs_url": "https://api.example.com/repos/{{ namespace }}/myproject5/git/refs{/sha}",
|
||||
"trees_url": "https://api.example.com/repos/{{ namespace }}/myproject5/git/trees{/sha}",
|
||||
"statuses_url": "https://api.example.com/repos/{{ namespace }}/myproject5/statuses/{sha}",
|
||||
"languages_url": "https://api.example.com/repos/{{ namespace }}/myproject5/languages",
|
||||
"stargazers_url": "https://api.example.com/repos/{{ namespace }}/myproject5/stargazers",
|
||||
"contributors_url": "https://api.example.com/repos/{{ namespace }}/myproject5/contributors",
|
||||
"subscribers_url": "https://api.example.com/repos/{{ namespace }}/myproject5/subscribers",
|
||||
"subscription_url": "https://api.example.com/repos/{{ namespace }}/myproject5/subscription",
|
||||
"commits_url": "https://api.example.com/repos/{{ namespace }}/myproject5/commits{/sha}",
|
||||
"git_commits_url": "https://api.example.com/repos/{{ namespace }}/myproject5/git/commits{/sha}",
|
||||
"comments_url": "https://api.example.com/repos/{{ namespace }}/myproject5/comments{/number}",
|
||||
"issue_comment_url": "https://api.example.com/repos/{{ namespace }}/myproject5/issues/comments{/number}",
|
||||
"contents_url": "https://api.example.com/repos/{{ namespace }}/myproject5/contents/{+path}",
|
||||
"compare_url": "https://api.example.com/repos/{{ namespace }}/myproject5/compare/{base}...{head}",
|
||||
"merges_url": "https://api.example.com/repos/{{ namespace }}/myproject5/merges",
|
||||
"archive_url": "https://api.example.com/repos/{{ namespace }}/myproject5/{archive_format}{/ref}",
|
||||
"downloads_url": "https://api.example.com/repos/{{ namespace }}/myproject5/downloads",
|
||||
"issues_url": "https://api.example.com/repos/{{ namespace }}/myproject5/issues{/number}",
|
||||
"pulls_url": "https://api.example.com/repos/{{ namespace }}/myproject5/pulls{/number}",
|
||||
"milestones_url": "https://api.example.com/repos/{{ namespace }}/myproject5/milestones{/number}",
|
||||
"notifications_url": "https://api.example.com/repos/{{ namespace }}/myproject5/notifications{?since,all,participating}",
|
||||
"labels_url": "https://api.example.com/repos/{{ namespace }}/myproject5/labels{/name}",
|
||||
"releases_url": "https://api.example.com/repos/{{ namespace }}/myproject5/releases{/id}",
|
||||
"deployments_url": "https://api.example.com/repos/{{ namespace }}/myproject5/deployments",
|
||||
"created_at": "2016-01-07T22:27:54Z",
|
||||
"updated_at": "2021-11-20T16:15:37Z",
|
||||
"pushed_at": "2021-11-20T16:15:34Z",
|
||||
"git_url": "git://example.com/{{ namespace }}/myproject5.git",
|
||||
"ssh_url": "ssh://git@example.com/{{ namespace }}/myproject5.git",
|
||||
"clone_url": "https://example.com/{{ namespace }}/myproject5.git",
|
||||
"svn_url": "https://example.com/{{ namespace }}/myproject5",
|
||||
"homepage": null,
|
||||
"size": 12,
|
||||
"stargazers_count": 0,
|
||||
"watchers_count": 0,
|
||||
"language": "Shell",
|
||||
"has_issues": true,
|
||||
"has_projects": true,
|
||||
"has_downloads": true,
|
||||
"has_wiki": true,
|
||||
"has_pages": false,
|
||||
"forks_count": 0,
|
||||
"mirror_url": null,
|
||||
"archived": false,
|
||||
"disabled": false,
|
||||
"open_issues_count": 0,
|
||||
"license": {
|
||||
"key": "apache-2.0",
|
||||
"name": "Apache License 2.0",
|
||||
"spdx_id": "Apache-2.0",
|
||||
"url": "https://api.example.com/licenses/apache-2.0",
|
||||
"node_id": "MDc6TGljZW5zZTI="
|
||||
},
|
||||
"allow_forking": true,
|
||||
"is_template": false,
|
||||
"topics": [
|
||||
|
||||
],
|
||||
"visibility": "public",
|
||||
"forks": 0,
|
||||
"open_issues": 0,
|
||||
"watchers": 0,
|
||||
"default_branch": "master",
|
||||
"permissions": {
|
||||
"admin": true,
|
||||
"maintain": true,
|
||||
"push": true,
|
||||
"triage": true,
|
||||
"pull": true
|
||||
}
|
||||
}
|
||||
]
|
||||
46
e2e_tests/docker-rest/flask/github_api_user.json
Normal file
46
e2e_tests/docker-rest/flask/github_api_user.json
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"login": "myuser1",
|
||||
"id": 1,
|
||||
"node_id": "MDQ6VXNlcjE=",
|
||||
"avatar_url": "https://example.com/images/error/octocat_happy.gif",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.example.com/users/octocat",
|
||||
"html_url": "https://example.com/octocat",
|
||||
"followers_url": "https://api.example.com/users/octocat/followers",
|
||||
"following_url": "https://api.example.com/users/octocat/following{/other_user}",
|
||||
"gists_url": "https://api.example.com/users/octocat/gists{/gist_id}",
|
||||
"starred_url": "https://api.example.com/users/octocat/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.example.com/users/octocat/subscriptions",
|
||||
"organizations_url": "https://api.example.com/users/octocat/orgs",
|
||||
"repos_url": "https://api.example.com/users/octocat/repos",
|
||||
"events_url": "https://api.example.com/users/octocat/events{/privacy}",
|
||||
"received_events_url": "https://api.example.com/users/octocat/received_events",
|
||||
"type": "User",
|
||||
"site_admin": false,
|
||||
"name": "monalisa octocat",
|
||||
"company": "GitHub",
|
||||
"blog": "https://example.com/blog",
|
||||
"location": "San Francisco",
|
||||
"email": "octocat@example.com",
|
||||
"hireable": false,
|
||||
"bio": "There once was...",
|
||||
"twitter_username": "monatheoctocat",
|
||||
"public_repos": 2,
|
||||
"public_gists": 1,
|
||||
"followers": 20,
|
||||
"following": 0,
|
||||
"created_at": "2008-01-14T04:33:35Z",
|
||||
"updated_at": "2008-01-14T04:33:35Z",
|
||||
"private_gists": 81,
|
||||
"total_private_repos": 100,
|
||||
"owned_private_repos": 100,
|
||||
"disk_usage": 10000,
|
||||
"collaborators": 8,
|
||||
"two_factor_authentication": true,
|
||||
"plan": {
|
||||
"name": "Medium",
|
||||
"space": 400,
|
||||
"private_repos": 20,
|
||||
"collaborators": 0
|
||||
}
|
||||
}
|
||||
106
e2e_tests/docker-rest/flask/gitlab.py
Normal file
106
e2e_tests/docker-rest/flask/gitlab.py
Normal file
@@ -0,0 +1,106 @@
|
||||
import os.path
|
||||
|
||||
from app import app
|
||||
|
||||
from flask import Flask, request, abort, jsonify, make_response
|
||||
|
||||
import jinja2
|
||||
|
||||
|
||||
def check_headers():
|
||||
if request.headers.get("accept") != "application/json":
|
||||
app.logger.error("Invalid accept header")
|
||||
abort(500)
|
||||
auth_header = request.headers.get("authorization")
|
||||
if auth_header != "bearer authtoken":
|
||||
app.logger.error("Invalid authorization header: %s", auth_header)
|
||||
abort(
|
||||
make_response(
|
||||
jsonify(
|
||||
{
|
||||
"message": "Bad credentials",
|
||||
"documentation_url": "https://docs.example.com/rest",
|
||||
}
|
||||
),
|
||||
401,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def add_pagination(response, page, last_page):
|
||||
host = request.headers["host"]
|
||||
link_header = ""
|
||||
|
||||
def args(page):
|
||||
args = request.args.copy()
|
||||
args["page"] = page
|
||||
return "&".join([f"{k}={v}" for k, v in args.items()])
|
||||
|
||||
if page < last_page:
|
||||
link_header += (
|
||||
f'<{request.scheme}://{host}{request.path}?{args(page+1)}>; rel="next", '
|
||||
)
|
||||
link_header += (
|
||||
f'<{request.scheme}://{host}{request.path}?{args(last_page)}>; rel="last"'
|
||||
)
|
||||
response.headers["link"] = link_header
|
||||
|
||||
|
||||
def read_project_files(namespaces=[]):
|
||||
last_page = 4
|
||||
page = username = int(request.args.get("page", "1"))
|
||||
response_file = f"./gitlab_api_page_{page}.json"
|
||||
if not os.path.exists(response_file):
|
||||
return jsonify([])
|
||||
|
||||
response = make_response(
|
||||
jinja2.Template(open(response_file).read()).render(
|
||||
namespace=namespaces[page - 1]
|
||||
)
|
||||
)
|
||||
add_pagination(response, page, last_page)
|
||||
response.headers["content-type"] = "application/json"
|
||||
return response
|
||||
|
||||
|
||||
def single_namespaced_projects(namespace):
|
||||
return read_project_files([namespace] * 4)
|
||||
|
||||
|
||||
def mixed_projects(namespaces):
|
||||
return read_project_files(namespaces)
|
||||
|
||||
|
||||
@app.route("/gitlab/api/v4/users/<string:user>/projects")
|
||||
def gitlab_user_repos(user):
|
||||
check_headers()
|
||||
if user == "myuser1":
|
||||
return single_namespaced_projects("myuser1")
|
||||
return jsonify([])
|
||||
|
||||
|
||||
@app.route("/gitlab/api/v4/groups/<string:group>/projects")
|
||||
def gitlab_group_repos(group):
|
||||
check_headers()
|
||||
if not (
|
||||
request.args.get("include_subgroups") == "true"
|
||||
and request.args.get("archived") == "false"
|
||||
):
|
||||
abort(500, "wrong arguments")
|
||||
if group == "mygroup1":
|
||||
return single_namespaced_projects("mygroup1")
|
||||
return jsonify([])
|
||||
|
||||
|
||||
@app.route("/gitlab/api/v4/projects/")
|
||||
def gitlab_own_repos():
|
||||
check_headers()
|
||||
return mixed_projects(["myuser1", "myuser2", "mygroup1", "mygroup2"])
|
||||
|
||||
|
||||
@app.route("/gitlab/api/v4/user/")
|
||||
def gitlab_user():
|
||||
check_headers()
|
||||
response = make_response(open("./gitlab_api_user.json").read())
|
||||
response.headers["content-type"] = "application/json"
|
||||
return response
|
||||
236
e2e_tests/docker-rest/flask/gitlab_api_page_1.json
Normal file
236
e2e_tests/docker-rest/flask/gitlab_api_page_1.json
Normal file
@@ -0,0 +1,236 @@
|
||||
[
|
||||
{
|
||||
"id": 1,
|
||||
"description": "",
|
||||
"name": "myproject1",
|
||||
"name_with_namespace": "{{ namespace }} / myproject1",
|
||||
"path": "myproject1",
|
||||
"path_with_namespace": "{{ namespace }}/myproject1",
|
||||
"created_at": "2020-11-26T17:23:39.904Z",
|
||||
"default_branch": "master",
|
||||
"tag_list": [],
|
||||
"topics": [],
|
||||
"ssh_url_to_repo": "ssh://git@example.com/{{ namespace }}/myproject1.git",
|
||||
"http_url_to_repo": "https://example.com/{{ namespace }}/myproject1.git",
|
||||
"web_url": "https://example.com/{{ namespace }}/myproject1",
|
||||
"readme_url": null,
|
||||
"avatar_url": null,
|
||||
"forks_count": 0,
|
||||
"star_count": 0,
|
||||
"last_activity_at": "2020-11-26T17:23:39.904Z",
|
||||
"namespace": {
|
||||
"id": 3,
|
||||
"name": "{{ namespace }}",
|
||||
"path": "{{ namespace }}",
|
||||
"kind": "group",
|
||||
"full_path": "{{ namespace }}",
|
||||
"parent_id": null,
|
||||
"avatar_url": "/uploads/-/system/group/avatar/5/x.png",
|
||||
"web_url": "https://example.com/groups/{{ namespace }}"
|
||||
},
|
||||
"container_registry_image_prefix": "registry.example.com/{{ namespace }}/myproject1",
|
||||
"_links": {
|
||||
"self": "https://example.com/api/v4/projects/2",
|
||||
"issues": "https://example.com/api/v4/projects/2/issues",
|
||||
"merge_requests": "https://example.com/api/v4/projects/2/merge_requests",
|
||||
"repo_branches": "https://example.com/api/v4/projects/2/repository/branches",
|
||||
"labels": "https://example.com/api/v4/projects/2/labels",
|
||||
"events": "https://example.com/api/v4/projects/2/events",
|
||||
"members": "https://example.com/api/v4/projects/2/members",
|
||||
"cluster_agents": "https://example.com/api/v4/projects/2/cluster_agents"
|
||||
},
|
||||
"packages_enabled": true,
|
||||
"empty_repo": false,
|
||||
"archived": false,
|
||||
"visibility": "private",
|
||||
"resolve_outdated_diff_discussions": false,
|
||||
"container_expiration_policy": {
|
||||
"cadence": "1d",
|
||||
"enabled": false,
|
||||
"keep_n": 10,
|
||||
"older_than": "90d",
|
||||
"name_regex": ".*",
|
||||
"name_regex_keep": null,
|
||||
"next_run_at": "2020-11-27T17:23:39.927Z"
|
||||
},
|
||||
"issues_enabled": true,
|
||||
"merge_requests_enabled": true,
|
||||
"wiki_enabled": true,
|
||||
"jobs_enabled": true,
|
||||
"snippets_enabled": true,
|
||||
"container_registry_enabled": true,
|
||||
"service_desk_enabled": true,
|
||||
"service_desk_address": "contact-for-myproject1-2-issue-@incoming.example.com",
|
||||
"can_create_merge_request_in": true,
|
||||
"issues_access_level": "enabled",
|
||||
"repository_access_level": "enabled",
|
||||
"merge_requests_access_level": "enabled",
|
||||
"forking_access_level": "enabled",
|
||||
"wiki_access_level": "enabled",
|
||||
"builds_access_level": "enabled",
|
||||
"snippets_access_level": "enabled",
|
||||
"pages_access_level": "private",
|
||||
"operations_access_level": "enabled",
|
||||
"analytics_access_level": "enabled",
|
||||
"container_registry_access_level": "enabled",
|
||||
"security_and_compliance_access_level": "private",
|
||||
"emails_disabled": null,
|
||||
"shared_runners_enabled": true,
|
||||
"lfs_enabled": true,
|
||||
"creator_id": 1803951,
|
||||
"import_url": null,
|
||||
"import_type": null,
|
||||
"import_status": "none",
|
||||
"open_issues_count": 0,
|
||||
"ci_default_git_depth": 50,
|
||||
"ci_forward_deployment_enabled": true,
|
||||
"ci_job_token_scope_enabled": false,
|
||||
"ci_separated_caches": true,
|
||||
"public_jobs": true,
|
||||
"build_timeout": 3600,
|
||||
"auto_cancel_pending_pipelines": "enabled",
|
||||
"build_coverage_regex": null,
|
||||
"ci_config_path": "",
|
||||
"shared_with_groups": [],
|
||||
"only_allow_merge_if_pipeline_succeeds": false,
|
||||
"allow_merge_on_skipped_pipeline": null,
|
||||
"restrict_user_defined_variables": false,
|
||||
"request_access_enabled": true,
|
||||
"only_allow_merge_if_all_discussions_are_resolved": false,
|
||||
"remove_source_branch_after_merge": true,
|
||||
"printing_merge_request_link_enabled": true,
|
||||
"merge_method": "merge",
|
||||
"squash_option": "default_off",
|
||||
"enforce_auth_checks_on_uploads": true,
|
||||
"suggestion_commit_message": null,
|
||||
"merge_commit_template": null,
|
||||
"squash_commit_template": null,
|
||||
"auto_devops_enabled": false,
|
||||
"auto_devops_deploy_strategy": "continuous",
|
||||
"autoclose_referenced_issues": true,
|
||||
"keep_latest_artifact": true,
|
||||
"runner_token_expiration_interval": null,
|
||||
"external_authorization_classification_label": "",
|
||||
"requirements_enabled": false,
|
||||
"requirements_access_level": "enabled",
|
||||
"security_and_compliance_enabled": true,
|
||||
"compliance_frameworks": []
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"description": "",
|
||||
"name": "myproject2",
|
||||
"name_with_namespace": "{{ namespace }} / myproject2",
|
||||
"path": "myproject2",
|
||||
"path_with_namespace": "{{ namespace }}/myproject2",
|
||||
"created_at": "2020-11-26T17:23:39.904Z",
|
||||
"default_branch": "master",
|
||||
"tag_list": [],
|
||||
"topics": [],
|
||||
"ssh_url_to_repo": "ssh://git@example.com/{{ namespace }}/myproject2.git",
|
||||
"http_url_to_repo": "https://example.com/{{ namespace }}/myproject2.git",
|
||||
"web_url": "https://example.com/{{ namespace }}/myproject2",
|
||||
"readme_url": null,
|
||||
"avatar_url": null,
|
||||
"forks_count": 0,
|
||||
"star_count": 0,
|
||||
"last_activity_at": "2020-11-26T17:23:39.904Z",
|
||||
"namespace": {
|
||||
"id": 3,
|
||||
"name": "{{ namespace }}",
|
||||
"path": "{{ namespace }}",
|
||||
"kind": "group",
|
||||
"full_path": "{{ namespace }}",
|
||||
"parent_id": null,
|
||||
"avatar_url": "/uploads/-/system/group/avatar/5/x.png",
|
||||
"web_url": "https://example.com/groups/{{ namespace }}"
|
||||
},
|
||||
"container_registry_image_prefix": "registry.example.com/{{ namespace }}/myproject2",
|
||||
"_links": {
|
||||
"self": "https://example.com/api/v4/projects/2",
|
||||
"issues": "https://example.com/api/v4/projects/2/issues",
|
||||
"merge_requests": "https://example.com/api/v4/projects/2/merge_requests",
|
||||
"repo_branches": "https://example.com/api/v4/projects/2/repository/branches",
|
||||
"labels": "https://example.com/api/v4/projects/2/labels",
|
||||
"events": "https://example.com/api/v4/projects/2/events",
|
||||
"members": "https://example.com/api/v4/projects/2/members",
|
||||
"cluster_agents": "https://example.com/api/v4/projects/2/cluster_agents"
|
||||
},
|
||||
"packages_enabled": true,
|
||||
"empty_repo": false,
|
||||
"archived": false,
|
||||
"visibility": "public",
|
||||
"resolve_outdated_diff_discussions": false,
|
||||
"container_expiration_policy": {
|
||||
"cadence": "1d",
|
||||
"enabled": false,
|
||||
"keep_n": 10,
|
||||
"older_than": "90d",
|
||||
"name_regex": ".*",
|
||||
"name_regex_keep": null,
|
||||
"next_run_at": "2020-11-27T17:23:39.927Z"
|
||||
},
|
||||
"issues_enabled": true,
|
||||
"merge_requests_enabled": true,
|
||||
"wiki_enabled": true,
|
||||
"jobs_enabled": true,
|
||||
"snippets_enabled": true,
|
||||
"container_registry_enabled": true,
|
||||
"service_desk_enabled": true,
|
||||
"service_desk_address": "contact-for-myproject2-2-issue-@incoming.example.com",
|
||||
"can_create_merge_request_in": true,
|
||||
"issues_access_level": "enabled",
|
||||
"repository_access_level": "enabled",
|
||||
"merge_requests_access_level": "enabled",
|
||||
"forking_access_level": "enabled",
|
||||
"wiki_access_level": "enabled",
|
||||
"builds_access_level": "enabled",
|
||||
"snippets_access_level": "enabled",
|
||||
"pages_access_level": "private",
|
||||
"operations_access_level": "enabled",
|
||||
"analytics_access_level": "enabled",
|
||||
"container_registry_access_level": "enabled",
|
||||
"security_and_compliance_access_level": "private",
|
||||
"emails_disabled": null,
|
||||
"shared_runners_enabled": true,
|
||||
"lfs_enabled": true,
|
||||
"creator_id": 1803951,
|
||||
"import_url": null,
|
||||
"import_type": null,
|
||||
"import_status": "none",
|
||||
"open_issues_count": 0,
|
||||
"ci_default_git_depth": 50,
|
||||
"ci_forward_deployment_enabled": true,
|
||||
"ci_job_token_scope_enabled": false,
|
||||
"ci_separated_caches": true,
|
||||
"public_jobs": true,
|
||||
"build_timeout": 3600,
|
||||
"auto_cancel_pending_pipelines": "enabled",
|
||||
"build_coverage_regex": null,
|
||||
"ci_config_path": "",
|
||||
"shared_with_groups": [],
|
||||
"only_allow_merge_if_pipeline_succeeds": false,
|
||||
"allow_merge_on_skipped_pipeline": null,
|
||||
"restrict_user_defined_variables": false,
|
||||
"request_access_enabled": true,
|
||||
"only_allow_merge_if_all_discussions_are_resolved": false,
|
||||
"remove_source_branch_after_merge": true,
|
||||
"printing_merge_request_link_enabled": true,
|
||||
"merge_method": "merge",
|
||||
"squash_option": "default_off",
|
||||
"enforce_auth_checks_on_uploads": true,
|
||||
"suggestion_commit_message": null,
|
||||
"merge_commit_template": null,
|
||||
"squash_commit_template": null,
|
||||
"auto_devops_enabled": false,
|
||||
"auto_devops_deploy_strategy": "continuous",
|
||||
"autoclose_referenced_issues": true,
|
||||
"keep_latest_artifact": true,
|
||||
"runner_token_expiration_interval": null,
|
||||
"external_authorization_classification_label": "",
|
||||
"requirements_enabled": false,
|
||||
"requirements_access_level": "enabled",
|
||||
"security_and_compliance_enabled": true,
|
||||
"compliance_frameworks": []
|
||||
}
|
||||
]
|
||||
119
e2e_tests/docker-rest/flask/gitlab_api_page_2.json
Normal file
119
e2e_tests/docker-rest/flask/gitlab_api_page_2.json
Normal file
@@ -0,0 +1,119 @@
|
||||
[
|
||||
{
|
||||
"id": 3,
|
||||
"description": "",
|
||||
"name": "myproject3",
|
||||
"name_with_namespace": "{{ namespace }} / myproject3",
|
||||
"path": "myproject3",
|
||||
"path_with_namespace": "{{ namespace }}/myproject3",
|
||||
"created_at": "2020-11-26T17:23:39.904Z",
|
||||
"default_branch": "master",
|
||||
"tag_list": [],
|
||||
"topics": [],
|
||||
"ssh_url_to_repo": "ssh://git@example.com/{{ namespace }}/myproject3.git",
|
||||
"http_url_to_repo": "https://example.com/{{ namespace }}/myproject3.git",
|
||||
"web_url": "https://example.com/{{ namespace }}/myproject3",
|
||||
"readme_url": null,
|
||||
"avatar_url": null,
|
||||
"forks_count": 0,
|
||||
"star_count": 0,
|
||||
"last_activity_at": "2020-11-26T17:23:39.904Z",
|
||||
"namespace": {
|
||||
"id": 3,
|
||||
"name": "{{ namespace }}",
|
||||
"path": "{{ namespace }}",
|
||||
"kind": "group",
|
||||
"full_path": "{{ namespace }}",
|
||||
"parent_id": null,
|
||||
"avatar_url": "/uploads/-/system/group/avatar/5/x.png",
|
||||
"web_url": "https://example.com/groups/{{ namespace }}"
|
||||
},
|
||||
"container_registry_image_prefix": "registry.example.com/{{ namespace }}/myproject3",
|
||||
"_links": {
|
||||
"self": "https://example.com/api/v4/projects/2",
|
||||
"issues": "https://example.com/api/v4/projects/2/issues",
|
||||
"merge_requests": "https://example.com/api/v4/projects/2/merge_requests",
|
||||
"repo_branches": "https://example.com/api/v4/projects/2/repository/branches",
|
||||
"labels": "https://example.com/api/v4/projects/2/labels",
|
||||
"events": "https://example.com/api/v4/projects/2/events",
|
||||
"members": "https://example.com/api/v4/projects/2/members",
|
||||
"cluster_agents": "https://example.com/api/v4/projects/2/cluster_agents"
|
||||
},
|
||||
"packages_enabled": true,
|
||||
"empty_repo": false,
|
||||
"archived": false,
|
||||
"visibility": "public",
|
||||
"resolve_outdated_diff_discussions": false,
|
||||
"container_expiration_policy": {
|
||||
"cadence": "1d",
|
||||
"enabled": false,
|
||||
"keep_n": 10,
|
||||
"older_than": "90d",
|
||||
"name_regex": ".*",
|
||||
"name_regex_keep": null,
|
||||
"next_run_at": "2020-11-27T17:23:39.927Z"
|
||||
},
|
||||
"issues_enabled": true,
|
||||
"merge_requests_enabled": true,
|
||||
"wiki_enabled": true,
|
||||
"jobs_enabled": true,
|
||||
"snippets_enabled": true,
|
||||
"container_registry_enabled": true,
|
||||
"service_desk_enabled": true,
|
||||
"service_desk_address": "contact-for-myproject3-2-issue-@incoming.example.com",
|
||||
"can_create_merge_request_in": true,
|
||||
"issues_access_level": "enabled",
|
||||
"repository_access_level": "enabled",
|
||||
"merge_requests_access_level": "enabled",
|
||||
"forking_access_level": "enabled",
|
||||
"wiki_access_level": "enabled",
|
||||
"builds_access_level": "enabled",
|
||||
"snippets_access_level": "enabled",
|
||||
"pages_access_level": "private",
|
||||
"operations_access_level": "enabled",
|
||||
"analytics_access_level": "enabled",
|
||||
"container_registry_access_level": "enabled",
|
||||
"security_and_compliance_access_level": "private",
|
||||
"emails_disabled": null,
|
||||
"shared_runners_enabled": true,
|
||||
"lfs_enabled": true,
|
||||
"creator_id": 1803951,
|
||||
"import_url": null,
|
||||
"import_type": null,
|
||||
"import_status": "none",
|
||||
"open_issues_count": 0,
|
||||
"ci_default_git_depth": 50,
|
||||
"ci_forward_deployment_enabled": true,
|
||||
"ci_job_token_scope_enabled": false,
|
||||
"ci_separated_caches": true,
|
||||
"public_jobs": true,
|
||||
"build_timeout": 3600,
|
||||
"auto_cancel_pending_pipelines": "enabled",
|
||||
"build_coverage_regex": null,
|
||||
"ci_config_path": "",
|
||||
"shared_with_groups": [],
|
||||
"only_allow_merge_if_pipeline_succeeds": false,
|
||||
"allow_merge_on_skipped_pipeline": null,
|
||||
"restrict_user_defined_variables": false,
|
||||
"request_access_enabled": true,
|
||||
"only_allow_merge_if_all_discussions_are_resolved": false,
|
||||
"remove_source_branch_after_merge": true,
|
||||
"printing_merge_request_link_enabled": true,
|
||||
"merge_method": "merge",
|
||||
"squash_option": "default_off",
|
||||
"enforce_auth_checks_on_uploads": true,
|
||||
"suggestion_commit_message": null,
|
||||
"merge_commit_template": null,
|
||||
"squash_commit_template": null,
|
||||
"auto_devops_enabled": false,
|
||||
"auto_devops_deploy_strategy": "continuous",
|
||||
"autoclose_referenced_issues": true,
|
||||
"keep_latest_artifact": true,
|
||||
"runner_token_expiration_interval": null,
|
||||
"external_authorization_classification_label": "",
|
||||
"requirements_enabled": false,
|
||||
"requirements_access_level": "enabled",
|
||||
"security_and_compliance_enabled": true,
|
||||
"compliance_frameworks": []
|
||||
}
|
||||
]
|
||||
119
e2e_tests/docker-rest/flask/gitlab_api_page_3.json
Normal file
119
e2e_tests/docker-rest/flask/gitlab_api_page_3.json
Normal file
@@ -0,0 +1,119 @@
|
||||
[
|
||||
{
|
||||
"id": 4,
|
||||
"description": "",
|
||||
"name": "myproject4",
|
||||
"name_with_namespace": "{{ namespace }} / myproject4",
|
||||
"path": "myproject4",
|
||||
"path_with_namespace": "{{ namespace }}/myproject4",
|
||||
"created_at": "2020-11-26T17:23:39.904Z",
|
||||
"default_branch": "master",
|
||||
"tag_list": [],
|
||||
"topics": [],
|
||||
"ssh_url_to_repo": "ssh://git@example.com/{{ namespace }}/myproject4.git",
|
||||
"http_url_to_repo": "https://example.com/{{ namespace }}/myproject4.git",
|
||||
"web_url": "https://example.com/{{ namespace }}/myproject4",
|
||||
"readme_url": null,
|
||||
"avatar_url": null,
|
||||
"forks_count": 0,
|
||||
"star_count": 0,
|
||||
"last_activity_at": "2020-11-26T17:23:39.904Z",
|
||||
"namespace": {
|
||||
"id": 3,
|
||||
"name": "{{ namespace }}",
|
||||
"path": "{{ namespace }}",
|
||||
"kind": "group",
|
||||
"full_path": "{{ namespace }}",
|
||||
"parent_id": null,
|
||||
"avatar_url": "/uploads/-/system/group/avatar/5/x.png",
|
||||
"web_url": "https://example.com/groups/{{ namespace }}"
|
||||
},
|
||||
"container_registry_image_prefix": "registry.example.com/{{ namespace }}/myproject4",
|
||||
"_links": {
|
||||
"self": "https://example.com/api/v4/projects/2",
|
||||
"issues": "https://example.com/api/v4/projects/2/issues",
|
||||
"merge_requests": "https://example.com/api/v4/projects/2/merge_requests",
|
||||
"repo_branches": "https://example.com/api/v4/projects/2/repository/branches",
|
||||
"labels": "https://example.com/api/v4/projects/2/labels",
|
||||
"events": "https://example.com/api/v4/projects/2/events",
|
||||
"members": "https://example.com/api/v4/projects/2/members",
|
||||
"cluster_agents": "https://example.com/api/v4/projects/2/cluster_agents"
|
||||
},
|
||||
"packages_enabled": true,
|
||||
"empty_repo": false,
|
||||
"archived": false,
|
||||
"visibility": "public",
|
||||
"resolve_outdated_diff_discussions": false,
|
||||
"container_expiration_policy": {
|
||||
"cadence": "1d",
|
||||
"enabled": false,
|
||||
"keep_n": 10,
|
||||
"older_than": "90d",
|
||||
"name_regex": ".*",
|
||||
"name_regex_keep": null,
|
||||
"next_run_at": "2020-11-27T17:23:39.927Z"
|
||||
},
|
||||
"issues_enabled": true,
|
||||
"merge_requests_enabled": true,
|
||||
"wiki_enabled": true,
|
||||
"jobs_enabled": true,
|
||||
"snippets_enabled": true,
|
||||
"container_registry_enabled": true,
|
||||
"service_desk_enabled": true,
|
||||
"service_desk_address": "contact-for-myproject4-2-issue-@incoming.example.com",
|
||||
"can_create_merge_request_in": true,
|
||||
"issues_access_level": "enabled",
|
||||
"repository_access_level": "enabled",
|
||||
"merge_requests_access_level": "enabled",
|
||||
"forking_access_level": "enabled",
|
||||
"wiki_access_level": "enabled",
|
||||
"builds_access_level": "enabled",
|
||||
"snippets_access_level": "enabled",
|
||||
"pages_access_level": "private",
|
||||
"operations_access_level": "enabled",
|
||||
"analytics_access_level": "enabled",
|
||||
"container_registry_access_level": "enabled",
|
||||
"security_and_compliance_access_level": "private",
|
||||
"emails_disabled": null,
|
||||
"shared_runners_enabled": true,
|
||||
"lfs_enabled": true,
|
||||
"creator_id": 1803951,
|
||||
"import_url": null,
|
||||
"import_type": null,
|
||||
"import_status": "none",
|
||||
"open_issues_count": 0,
|
||||
"ci_default_git_depth": 50,
|
||||
"ci_forward_deployment_enabled": true,
|
||||
"ci_job_token_scope_enabled": false,
|
||||
"ci_separated_caches": true,
|
||||
"public_jobs": true,
|
||||
"build_timeout": 3600,
|
||||
"auto_cancel_pending_pipelines": "enabled",
|
||||
"build_coverage_regex": null,
|
||||
"ci_config_path": "",
|
||||
"shared_with_groups": [],
|
||||
"only_allow_merge_if_pipeline_succeeds": false,
|
||||
"allow_merge_on_skipped_pipeline": null,
|
||||
"restrict_user_defined_variables": false,
|
||||
"request_access_enabled": true,
|
||||
"only_allow_merge_if_all_discussions_are_resolved": false,
|
||||
"remove_source_branch_after_merge": true,
|
||||
"printing_merge_request_link_enabled": true,
|
||||
"merge_method": "merge",
|
||||
"squash_option": "default_off",
|
||||
"enforce_auth_checks_on_uploads": true,
|
||||
"suggestion_commit_message": null,
|
||||
"merge_commit_template": null,
|
||||
"squash_commit_template": null,
|
||||
"auto_devops_enabled": false,
|
||||
"auto_devops_deploy_strategy": "continuous",
|
||||
"autoclose_referenced_issues": true,
|
||||
"keep_latest_artifact": true,
|
||||
"runner_token_expiration_interval": null,
|
||||
"external_authorization_classification_label": "",
|
||||
"requirements_enabled": false,
|
||||
"requirements_access_level": "enabled",
|
||||
"security_and_compliance_enabled": true,
|
||||
"compliance_frameworks": []
|
||||
}
|
||||
]
|
||||
119
e2e_tests/docker-rest/flask/gitlab_api_page_4.json
Normal file
119
e2e_tests/docker-rest/flask/gitlab_api_page_4.json
Normal file
@@ -0,0 +1,119 @@
|
||||
[
|
||||
{
|
||||
"id": 5,
|
||||
"description": "",
|
||||
"name": "myproject5",
|
||||
"name_with_namespace": "{{ namespace }} / myproject5",
|
||||
"path": "myproject5",
|
||||
"path_with_namespace": "{{ namespace }}/myproject5",
|
||||
"created_at": "2020-11-26T17:23:39.904Z",
|
||||
"default_branch": "master",
|
||||
"tag_list": [],
|
||||
"topics": [],
|
||||
"ssh_url_to_repo": "ssh://git@example.com/{{ namespace }}/myproject5.git",
|
||||
"http_url_to_repo": "https://example.com/{{ namespace }}/myproject5.git",
|
||||
"web_url": "https://example.com/{{ namespace }}/myproject5",
|
||||
"readme_url": null,
|
||||
"avatar_url": null,
|
||||
"forks_count": 0,
|
||||
"star_count": 0,
|
||||
"last_activity_at": "2020-11-26T17:23:39.904Z",
|
||||
"namespace": {
|
||||
"id": 3,
|
||||
"name": "{{ namespace }}",
|
||||
"path": "{{ namespace }}",
|
||||
"kind": "group",
|
||||
"full_path": "{{ namespace }}",
|
||||
"parent_id": null,
|
||||
"avatar_url": "/uploads/-/system/group/avatar/5/x.png",
|
||||
"web_url": "https://example.com/groups/{{ namespace }}"
|
||||
},
|
||||
"container_registry_image_prefix": "registry.example.com/{{ namespace }}/myproject5",
|
||||
"_links": {
|
||||
"self": "https://example.com/api/v4/projects/2",
|
||||
"issues": "https://example.com/api/v4/projects/2/issues",
|
||||
"merge_requests": "https://example.com/api/v4/projects/2/merge_requests",
|
||||
"repo_branches": "https://example.com/api/v4/projects/2/repository/branches",
|
||||
"labels": "https://example.com/api/v4/projects/2/labels",
|
||||
"events": "https://example.com/api/v4/projects/2/events",
|
||||
"members": "https://example.com/api/v4/projects/2/members",
|
||||
"cluster_agents": "https://example.com/api/v4/projects/2/cluster_agents"
|
||||
},
|
||||
"packages_enabled": true,
|
||||
"empty_repo": false,
|
||||
"archived": false,
|
||||
"visibility": "public",
|
||||
"resolve_outdated_diff_discussions": false,
|
||||
"container_expiration_policy": {
|
||||
"cadence": "1d",
|
||||
"enabled": false,
|
||||
"keep_n": 10,
|
||||
"older_than": "90d",
|
||||
"name_regex": ".*",
|
||||
"name_regex_keep": null,
|
||||
"next_run_at": "2020-11-27T17:23:39.927Z"
|
||||
},
|
||||
"issues_enabled": true,
|
||||
"merge_requests_enabled": true,
|
||||
"wiki_enabled": true,
|
||||
"jobs_enabled": true,
|
||||
"snippets_enabled": true,
|
||||
"container_registry_enabled": true,
|
||||
"service_desk_enabled": true,
|
||||
"service_desk_address": "contact-for-myproject5-2-issue-@incoming.example.com",
|
||||
"can_create_merge_request_in": true,
|
||||
"issues_access_level": "enabled",
|
||||
"repository_access_level": "enabled",
|
||||
"merge_requests_access_level": "enabled",
|
||||
"forking_access_level": "enabled",
|
||||
"wiki_access_level": "enabled",
|
||||
"builds_access_level": "enabled",
|
||||
"snippets_access_level": "enabled",
|
||||
"pages_access_level": "private",
|
||||
"operations_access_level": "enabled",
|
||||
"analytics_access_level": "enabled",
|
||||
"container_registry_access_level": "enabled",
|
||||
"security_and_compliance_access_level": "private",
|
||||
"emails_disabled": null,
|
||||
"shared_runners_enabled": true,
|
||||
"lfs_enabled": true,
|
||||
"creator_id": 1803951,
|
||||
"import_url": null,
|
||||
"import_type": null,
|
||||
"import_status": "none",
|
||||
"open_issues_count": 0,
|
||||
"ci_default_git_depth": 50,
|
||||
"ci_forward_deployment_enabled": true,
|
||||
"ci_job_token_scope_enabled": false,
|
||||
"ci_separated_caches": true,
|
||||
"public_jobs": true,
|
||||
"build_timeout": 3600,
|
||||
"auto_cancel_pending_pipelines": "enabled",
|
||||
"build_coverage_regex": null,
|
||||
"ci_config_path": "",
|
||||
"shared_with_groups": [],
|
||||
"only_allow_merge_if_pipeline_succeeds": false,
|
||||
"allow_merge_on_skipped_pipeline": null,
|
||||
"restrict_user_defined_variables": false,
|
||||
"request_access_enabled": true,
|
||||
"only_allow_merge_if_all_discussions_are_resolved": false,
|
||||
"remove_source_branch_after_merge": true,
|
||||
"printing_merge_request_link_enabled": true,
|
||||
"merge_method": "merge",
|
||||
"squash_option": "default_off",
|
||||
"enforce_auth_checks_on_uploads": true,
|
||||
"suggestion_commit_message": null,
|
||||
"merge_commit_template": null,
|
||||
"squash_commit_template": null,
|
||||
"auto_devops_enabled": false,
|
||||
"auto_devops_deploy_strategy": "continuous",
|
||||
"autoclose_referenced_issues": true,
|
||||
"keep_latest_artifact": true,
|
||||
"runner_token_expiration_interval": null,
|
||||
"external_authorization_classification_label": "",
|
||||
"requirements_enabled": false,
|
||||
"requirements_access_level": "enabled",
|
||||
"security_and_compliance_enabled": true,
|
||||
"compliance_frameworks": []
|
||||
}
|
||||
]
|
||||
42
e2e_tests/docker-rest/flask/gitlab_api_user.json
Normal file
42
e2e_tests/docker-rest/flask/gitlab_api_user.json
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"id": 1,
|
||||
"username": "myuser1",
|
||||
"name": "My User",
|
||||
"state": "active",
|
||||
"avatar_url": "https://example.com/avatar",
|
||||
"web_url": "https://example.com/myuser1",
|
||||
"created_at": "2016-12-10T10:09:11.585Z",
|
||||
"bio": "",
|
||||
"location": "",
|
||||
"public_email": "",
|
||||
"skype": "",
|
||||
"linkedin": "",
|
||||
"twitter": "",
|
||||
"website_url": "",
|
||||
"organization": "",
|
||||
"job_title": "",
|
||||
"pronouns": "",
|
||||
"bot": false,
|
||||
"work_information": null,
|
||||
"followers": 0,
|
||||
"following": 0,
|
||||
"is_followed": false,
|
||||
"local_time": "11:59 PM",
|
||||
"last_sign_in_at": "2020-03-14T09:13:44.977Z",
|
||||
"confirmed_at": "2022-05-19T23:48:47.033Z",
|
||||
"last_activity_on": "2022-05-19",
|
||||
"email": "myuser1@example.com",
|
||||
"theme_id": null,
|
||||
"color_scheme_id": 1,
|
||||
"projects_limit": 100000,
|
||||
"current_sign_in_at": "2022-05-19T23:45:49.661Z",
|
||||
"identities": [],
|
||||
"can_create_group": true,
|
||||
"can_create_project": true,
|
||||
"two_factor_enabled": false,
|
||||
"external": false,
|
||||
"private_profile": false,
|
||||
"commit_email": "myuser1@example.com",
|
||||
"shared_runners_minutes_limit": 2000,
|
||||
"extra_shared_runners_minutes_limit": null
|
||||
}
|
||||
14
e2e_tests/docker/Dockerfile
Normal file
14
e2e_tests/docker/Dockerfile
Normal file
@@ -0,0 +1,14 @@
|
||||
FROM docker.io/debian:11.3
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y \
|
||||
python3-pytest \
|
||||
python3-toml \
|
||||
python3-git \
|
||||
python3-yaml \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /tests
|
||||
|
||||
ENTRYPOINT ["/bin/sh", "-c", "--"]
|
||||
@@ -8,9 +8,7 @@ import hashlib
|
||||
|
||||
import git
|
||||
|
||||
binary = os.path.join(
|
||||
os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "target/release/grm"
|
||||
)
|
||||
binary = os.environ["GRM_BINARY"]
|
||||
|
||||
|
||||
def grm(args, cwd=None, is_invalid=False):
|
||||
@@ -208,7 +206,7 @@ class RepoTree:
|
||||
"""
|
||||
)
|
||||
|
||||
cmd = grm(["repos", "sync", "--config", self.config.name])
|
||||
cmd = grm(["repos", "sync", "config", "--config", self.config.name])
|
||||
assert cmd.returncode == 0
|
||||
return (self.root.name, self.config.name, ["test", "test_worktree"])
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
attrs==21.4.0
|
||||
gitdb==4.0.9
|
||||
GitPython==3.1.27
|
||||
iniconfig==1.1.1
|
||||
packaging==21.3
|
||||
pluggy==1.0.0
|
||||
py==1.11.0
|
||||
pyparsing==3.0.8
|
||||
pytest==7.1.2
|
||||
PyYAML==6.0
|
||||
smmap==5.0.0
|
||||
toml==0.10.2
|
||||
tomli==2.0.1
|
||||
typing_extensions==4.2.0
|
||||
@@ -11,7 +11,7 @@ from helpers import *
|
||||
|
||||
def test_repos_find_nonexistent():
|
||||
with NonExistentPath() as nonexistent_dir:
|
||||
cmd = grm(["repos", "find", nonexistent_dir])
|
||||
cmd = grm(["repos", "find", "local", nonexistent_dir])
|
||||
assert "does not exist" in cmd.stderr.lower()
|
||||
assert cmd.returncode != 0
|
||||
assert not os.path.exists(nonexistent_dir)
|
||||
@@ -19,14 +19,14 @@ def test_repos_find_nonexistent():
|
||||
|
||||
def test_repos_find_file():
|
||||
with tempfile.NamedTemporaryFile() as tmpfile:
|
||||
cmd = grm(["repos", "find", tmpfile.name])
|
||||
cmd = grm(["repos", "find", "local", tmpfile.name])
|
||||
assert "not a directory" in cmd.stderr.lower()
|
||||
assert cmd.returncode != 0
|
||||
|
||||
|
||||
def test_repos_find_empty():
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
cmd = grm(["repos", "find", tmpdir])
|
||||
cmd = grm(["repos", "find", "local", tmpdir])
|
||||
assert cmd.returncode == 0
|
||||
assert len(cmd.stdout) == 0
|
||||
assert len(cmd.stderr) != 0
|
||||
@@ -35,7 +35,8 @@ def test_repos_find_empty():
|
||||
def test_repos_find_invalid_format():
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
cmd = grm(
|
||||
["repos", "find", tmpdir, "--format", "invalidformat"], is_invalid=True
|
||||
["repos", "find", "local", tmpdir, "--format", "invalidformat"],
|
||||
is_invalid=True,
|
||||
)
|
||||
assert cmd.returncode != 0
|
||||
assert len(cmd.stdout) == 0
|
||||
@@ -55,7 +56,7 @@ def test_repos_find_non_git_repos():
|
||||
"""
|
||||
)
|
||||
|
||||
cmd = grm(["repos", "find", tmpdir])
|
||||
cmd = grm(["repos", "find", "local", tmpdir])
|
||||
|
||||
assert cmd.returncode == 0
|
||||
assert len(cmd.stdout) == 0
|
||||
@@ -83,7 +84,7 @@ def test_repos_find(configtype, default):
|
||||
(
|
||||
cd ./repo2
|
||||
git init
|
||||
git co -b main
|
||||
git checkout -b main
|
||||
echo test > test
|
||||
git add test
|
||||
git commit -m "commit1"
|
||||
@@ -97,7 +98,7 @@ def test_repos_find(configtype, default):
|
||||
"""
|
||||
)
|
||||
|
||||
args = ["repos", "find", tmpdir]
|
||||
args = ["repos", "find", "local", tmpdir]
|
||||
if not default:
|
||||
args += ["--format", configtype]
|
||||
cmd = grm(args)
|
||||
@@ -152,7 +153,7 @@ def test_repos_find(configtype, default):
|
||||
def test_repos_find_in_root(configtype, default):
|
||||
with TempGitRepository() as repo_dir:
|
||||
|
||||
args = ["repos", "find", repo_dir]
|
||||
args = ["repos", "find", "local", repo_dir]
|
||||
if not default:
|
||||
args += ["--format", configtype]
|
||||
cmd = grm(args)
|
||||
@@ -213,7 +214,7 @@ def test_repos_find_with_invalid_repo(configtype, default):
|
||||
(
|
||||
cd ./repo2
|
||||
git init
|
||||
git co -b main
|
||||
git checkout -b main
|
||||
echo test > test
|
||||
git add test
|
||||
git commit -m "commit1"
|
||||
@@ -227,7 +228,7 @@ def test_repos_find_with_invalid_repo(configtype, default):
|
||||
"""
|
||||
)
|
||||
|
||||
args = ["repos", "find", tmpdir]
|
||||
args = ["repos", "find", "local", tmpdir]
|
||||
if not default:
|
||||
args += ["--format", configtype]
|
||||
cmd = grm(args)
|
||||
|
||||
950
e2e_tests/test_repos_find_remote.py
Normal file
950
e2e_tests/test_repos_find_remote.py
Normal file
@@ -0,0 +1,950 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import re
|
||||
import os
|
||||
|
||||
import toml
|
||||
import pytest
|
||||
import yaml
|
||||
|
||||
from helpers import *
|
||||
|
||||
|
||||
ALTERNATE_DOMAIN = os.environ["ALTERNATE_DOMAIN"]
|
||||
PROVIDERS = ["github", "gitlab"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("use_config", [True, False])
|
||||
def test_repos_find_remote_invalid_provider(use_config):
|
||||
if use_config:
|
||||
with tempfile.NamedTemporaryFile() as config:
|
||||
with open(config.name, "w") as f:
|
||||
f.write(
|
||||
"""
|
||||
provider = "thisproviderdoesnotexist"
|
||||
token_command = "true"
|
||||
root = "/"
|
||||
"""
|
||||
)
|
||||
args = ["repos", "find", "config", "--config", config.name]
|
||||
cmd = grm(args, is_invalid=True)
|
||||
else:
|
||||
args = [
|
||||
"repos",
|
||||
"find",
|
||||
"remote",
|
||||
"--provider",
|
||||
"thisproviderdoesnotexist",
|
||||
"--token-command",
|
||||
"true",
|
||||
"--root",
|
||||
"/",
|
||||
]
|
||||
cmd = grm(args, is_invalid=True)
|
||||
assert cmd.returncode != 0
|
||||
assert len(cmd.stdout) == 0
|
||||
if not use_config:
|
||||
assert re.match(".*isn't a valid value for.*provider", cmd.stderr)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("provider", PROVIDERS)
|
||||
def test_repos_find_remote_invalid_format(provider):
|
||||
cmd = grm(
|
||||
[
|
||||
"repos",
|
||||
"find",
|
||||
"remote",
|
||||
"--provider",
|
||||
provider,
|
||||
"--format",
|
||||
"invalidformat",
|
||||
"--token-command",
|
||||
"true",
|
||||
"--root",
|
||||
"/myroot",
|
||||
],
|
||||
is_invalid=True,
|
||||
)
|
||||
assert cmd.returncode != 0
|
||||
assert len(cmd.stdout) == 0
|
||||
assert "isn't a valid value" in cmd.stderr
|
||||
|
||||
|
||||
@pytest.mark.parametrize("provider", PROVIDERS)
|
||||
def test_repos_find_remote_token_command_failed(provider):
|
||||
cmd = grm(
|
||||
[
|
||||
"repos",
|
||||
"find",
|
||||
"remote",
|
||||
"--provider",
|
||||
provider,
|
||||
"--format",
|
||||
"yaml",
|
||||
"--token-command",
|
||||
"false",
|
||||
"--root",
|
||||
"/myroot",
|
||||
],
|
||||
is_invalid=True,
|
||||
)
|
||||
assert cmd.returncode != 0
|
||||
assert len(cmd.stdout) == 0
|
||||
assert "token command failed" in cmd.stderr.lower()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("provider", PROVIDERS)
|
||||
@pytest.mark.parametrize("use_config", [True, False])
|
||||
def test_repos_find_remote_wrong_token(provider, use_config):
|
||||
if use_config:
|
||||
with tempfile.NamedTemporaryFile() as config:
|
||||
with open(config.name, "w") as f:
|
||||
f.write(
|
||||
f"""
|
||||
provider = "{provider}"
|
||||
token_command = "echo wrongtoken"
|
||||
root = "/myroot"
|
||||
[filters]
|
||||
access = true
|
||||
"""
|
||||
)
|
||||
args = ["repos", "find", "config", "--config", config.name]
|
||||
cmd = grm(args, is_invalid=True)
|
||||
else:
|
||||
args = [
|
||||
"repos",
|
||||
"find",
|
||||
"remote",
|
||||
"--provider",
|
||||
provider,
|
||||
"--token-command",
|
||||
"echo wrongtoken",
|
||||
"--root",
|
||||
"/myroot",
|
||||
"--access",
|
||||
]
|
||||
cmd = grm(args, is_invalid=True)
|
||||
|
||||
assert cmd.returncode != 0
|
||||
assert len(cmd.stdout) == 0
|
||||
assert "bad credentials" in cmd.stderr.lower()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("provider", PROVIDERS)
|
||||
@pytest.mark.parametrize("default", [True, False])
|
||||
@pytest.mark.parametrize("configtype", ["toml", "yaml"])
|
||||
@pytest.mark.parametrize("use_config", [True, False])
|
||||
def test_repos_find_remote_no_filter(provider, configtype, default, use_config):
|
||||
if use_config:
|
||||
with tempfile.NamedTemporaryFile() as config:
|
||||
with open(config.name, "w") as f:
|
||||
f.write(
|
||||
f"""
|
||||
provider = "{provider}"
|
||||
token_command = "echo authtoken"
|
||||
root = "/myroot"
|
||||
"""
|
||||
)
|
||||
args = ["repos", "find", "config", "--config", config.name]
|
||||
if not default:
|
||||
args += ["--format", configtype]
|
||||
cmd = grm(args)
|
||||
else:
|
||||
args = [
|
||||
"repos",
|
||||
"find",
|
||||
"remote",
|
||||
"--provider",
|
||||
provider,
|
||||
"--token-command",
|
||||
"echo authtoken",
|
||||
"--root",
|
||||
"/myroot",
|
||||
]
|
||||
if not default:
|
||||
args += ["--format", configtype]
|
||||
cmd = grm(args)
|
||||
|
||||
assert cmd.returncode == 0
|
||||
assert len(cmd.stderr) == 0
|
||||
|
||||
if default or configtype == "toml":
|
||||
output = toml.loads(cmd.stdout)
|
||||
elif configtype == "yaml":
|
||||
output = yaml.safe_load(cmd.stdout)
|
||||
else:
|
||||
raise NotImplementedError()
|
||||
|
||||
assert isinstance(output, dict)
|
||||
assert set(output.keys()) == {"trees"}
|
||||
assert isinstance(output["trees"], list)
|
||||
assert len(output["trees"]) == 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize("provider", PROVIDERS)
|
||||
@pytest.mark.parametrize("configtype_default", [True, False])
|
||||
@pytest.mark.parametrize("configtype", ["toml", "yaml"])
|
||||
@pytest.mark.parametrize("use_config", [True, False])
|
||||
def test_repos_find_remote_user_empty(
|
||||
provider, configtype, configtype_default, use_config
|
||||
):
|
||||
if use_config:
|
||||
with tempfile.NamedTemporaryFile() as config:
|
||||
with open(config.name, "w") as f:
|
||||
cfg = f"""
|
||||
provider = "{provider}"
|
||||
token_command = "echo authtoken"
|
||||
root = "/myroot"
|
||||
|
||||
[filters]
|
||||
users = ["someotheruser"]
|
||||
"""
|
||||
|
||||
f.write(cfg)
|
||||
args = ["repos", "find", "config", "--config", config.name]
|
||||
if not configtype_default:
|
||||
args += ["--format", configtype]
|
||||
cmd = grm(args)
|
||||
else:
|
||||
args = [
|
||||
"repos",
|
||||
"find",
|
||||
"remote",
|
||||
"--provider",
|
||||
provider,
|
||||
"--token-command",
|
||||
"echo authtoken",
|
||||
"--root",
|
||||
"/myroot",
|
||||
"--user",
|
||||
"someotheruser",
|
||||
]
|
||||
|
||||
if not configtype_default:
|
||||
args += ["--format", configtype]
|
||||
cmd = grm(args)
|
||||
assert cmd.returncode == 0
|
||||
assert len(cmd.stderr) == 0
|
||||
|
||||
if configtype_default or configtype == "toml":
|
||||
output = toml.loads(cmd.stdout)
|
||||
elif configtype == "yaml":
|
||||
output = yaml.safe_load(cmd.stdout)
|
||||
else:
|
||||
raise NotImplementedError()
|
||||
|
||||
assert isinstance(output, dict)
|
||||
assert set(output.keys()) == {"trees"}
|
||||
assert isinstance(output["trees"], list)
|
||||
assert len(output["trees"]) == 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize("provider", PROVIDERS)
|
||||
@pytest.mark.parametrize("configtype_default", [True, False])
|
||||
@pytest.mark.parametrize("configtype", ["toml", "yaml"])
|
||||
@pytest.mark.parametrize("worktree_default", [True, False])
|
||||
@pytest.mark.parametrize("worktree", [True, False])
|
||||
@pytest.mark.parametrize("use_owner", [True, False])
|
||||
@pytest.mark.parametrize("force_ssh", [True, False])
|
||||
@pytest.mark.parametrize("use_alternate_endpoint", [True, False])
|
||||
@pytest.mark.parametrize("use_config", [True, False])
|
||||
def test_repos_find_remote_user(
|
||||
provider,
|
||||
configtype,
|
||||
configtype_default,
|
||||
worktree,
|
||||
worktree_default,
|
||||
use_owner,
|
||||
force_ssh,
|
||||
use_alternate_endpoint,
|
||||
use_config,
|
||||
):
|
||||
if use_config:
|
||||
with tempfile.NamedTemporaryFile() as config:
|
||||
with open(config.name, "w") as f:
|
||||
cfg = f"""
|
||||
provider = "{provider}"
|
||||
token_command = "echo authtoken"
|
||||
root = "/myroot"
|
||||
"""
|
||||
|
||||
if use_alternate_endpoint:
|
||||
cfg += f'api_url = "http://{ALTERNATE_DOMAIN}:5000/{provider}"\n'
|
||||
if not worktree_default:
|
||||
cfg += f"worktree = {str(worktree).lower()}\n"
|
||||
if force_ssh:
|
||||
cfg += f"force_ssh = true\n"
|
||||
if use_owner:
|
||||
cfg += """
|
||||
[filters]
|
||||
owner = true\n
|
||||
"""
|
||||
else:
|
||||
cfg += """
|
||||
[filters]
|
||||
users = ["myuser1"]\n
|
||||
"""
|
||||
|
||||
print(cfg)
|
||||
f.write(cfg)
|
||||
|
||||
args = ["repos", "find", "config", "--config", config.name]
|
||||
if not configtype_default:
|
||||
args += ["--format", configtype]
|
||||
cmd = grm(args)
|
||||
else:
|
||||
args = [
|
||||
"repos",
|
||||
"find",
|
||||
"remote",
|
||||
"--provider",
|
||||
provider,
|
||||
"--token-command",
|
||||
"echo authtoken",
|
||||
"--root",
|
||||
"/myroot",
|
||||
]
|
||||
if use_owner:
|
||||
args += ["--owner"]
|
||||
else:
|
||||
args += ["--user", "myuser1"]
|
||||
if force_ssh:
|
||||
args += ["--force-ssh"]
|
||||
if not worktree_default:
|
||||
args += ["--worktree", str(worktree).lower()]
|
||||
if use_alternate_endpoint:
|
||||
args += ["--api-url", f"http://{ALTERNATE_DOMAIN}:5000/{provider}"]
|
||||
|
||||
if not configtype_default:
|
||||
args += ["--format", configtype]
|
||||
cmd = grm(args)
|
||||
|
||||
if use_alternate_endpoint and provider == "github":
|
||||
assert cmd.returncode != 0
|
||||
assert "overriding is not supported for github" in cmd.stderr.lower()
|
||||
return
|
||||
|
||||
assert cmd.returncode == 0
|
||||
assert len(cmd.stderr) == 0
|
||||
|
||||
if configtype_default or configtype == "toml":
|
||||
output = toml.loads(cmd.stdout)
|
||||
elif configtype == "yaml":
|
||||
output = yaml.safe_load(cmd.stdout)
|
||||
else:
|
||||
raise NotImplementedError()
|
||||
|
||||
assert isinstance(output, dict)
|
||||
assert set(output.keys()) == {"trees"}
|
||||
assert isinstance(output["trees"], list)
|
||||
assert len(output["trees"]) == 1
|
||||
|
||||
assert set(output["trees"][0].keys()) == {"root", "repos"}
|
||||
assert isinstance(output["trees"][0]["repos"], list)
|
||||
assert len(output["trees"][0]["repos"]) == 5
|
||||
|
||||
for i in range(1, 6):
|
||||
repo = [r for r in output["trees"][0]["repos"] if r["name"] == f"myproject{i}"][
|
||||
0
|
||||
]
|
||||
assert repo["worktree_setup"] is (not worktree_default and worktree)
|
||||
assert isinstance(repo["remotes"], list)
|
||||
assert len(repo["remotes"]) == 1
|
||||
assert repo["remotes"][0]["name"] == provider
|
||||
if force_ssh or i == 1:
|
||||
assert (
|
||||
repo["remotes"][0]["url"]
|
||||
== f"ssh://git@example.com/myuser1/myproject{i}.git"
|
||||
)
|
||||
assert repo["remotes"][0]["type"] == "ssh"
|
||||
else:
|
||||
assert (
|
||||
repo["remotes"][0]["url"]
|
||||
== f"https://example.com/myuser1/myproject{i}.git"
|
||||
)
|
||||
assert repo["remotes"][0]["type"] == "https"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("provider", PROVIDERS)
|
||||
@pytest.mark.parametrize("configtype_default", [False])
|
||||
@pytest.mark.parametrize("configtype", ["toml", "yaml"])
|
||||
@pytest.mark.parametrize("use_alternate_endpoint", [True, False])
|
||||
@pytest.mark.parametrize("use_config", [True, False])
|
||||
def test_repos_find_remote_group_empty(
|
||||
provider, configtype, configtype_default, use_alternate_endpoint, use_config
|
||||
):
|
||||
if use_config:
|
||||
with tempfile.NamedTemporaryFile() as config:
|
||||
with open(config.name, "w") as f:
|
||||
cfg = f"""
|
||||
provider = "{provider}"
|
||||
token_command = "echo authtoken"
|
||||
root = "/myroot"
|
||||
"""
|
||||
|
||||
if use_alternate_endpoint:
|
||||
cfg += f'api_url = "http://{ALTERNATE_DOMAIN}:5000/{provider}"\n'
|
||||
cfg += """
|
||||
[filters]
|
||||
groups = ["someothergroup"]\n
|
||||
"""
|
||||
|
||||
f.write(cfg)
|
||||
|
||||
args = ["repos", "find", "config", "--config", config.name]
|
||||
if not configtype_default:
|
||||
args += ["--format", configtype]
|
||||
cmd = grm(args)
|
||||
else:
|
||||
args = [
|
||||
"repos",
|
||||
"find",
|
||||
"remote",
|
||||
"--provider",
|
||||
provider,
|
||||
"--token-command",
|
||||
"echo authtoken",
|
||||
"--root",
|
||||
"/myroot",
|
||||
"--group",
|
||||
"someothergroup",
|
||||
]
|
||||
if use_alternate_endpoint:
|
||||
args += ["--api-url", f"http://{ALTERNATE_DOMAIN}:5000/{provider}"]
|
||||
|
||||
if not configtype_default:
|
||||
args += ["--format", configtype]
|
||||
cmd = grm(args)
|
||||
|
||||
if use_alternate_endpoint and provider == "github":
|
||||
assert cmd.returncode != 0
|
||||
assert "overriding is not supported for github" in cmd.stderr.lower()
|
||||
return
|
||||
assert cmd.returncode == 0
|
||||
assert len(cmd.stderr) == 0
|
||||
|
||||
if configtype_default or configtype == "toml":
|
||||
output = toml.loads(cmd.stdout)
|
||||
elif configtype == "yaml":
|
||||
output = yaml.safe_load(cmd.stdout)
|
||||
else:
|
||||
raise NotImplementedError()
|
||||
|
||||
assert isinstance(output, dict)
|
||||
assert set(output.keys()) == {"trees"}
|
||||
assert isinstance(output["trees"], list)
|
||||
assert len(output["trees"]) == 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize("provider", PROVIDERS)
|
||||
@pytest.mark.parametrize("configtype_default", [False])
|
||||
@pytest.mark.parametrize("configtype", ["toml", "yaml"])
|
||||
@pytest.mark.parametrize("worktree_default", [True, False])
|
||||
@pytest.mark.parametrize("worktree", [True, False])
|
||||
@pytest.mark.parametrize("force_ssh", [True, False])
|
||||
@pytest.mark.parametrize("use_alternate_endpoint", [True, False])
|
||||
@pytest.mark.parametrize("use_config", [True, False])
|
||||
def test_repos_find_remote_group(
|
||||
provider,
|
||||
configtype,
|
||||
configtype_default,
|
||||
worktree,
|
||||
worktree_default,
|
||||
force_ssh,
|
||||
use_alternate_endpoint,
|
||||
use_config,
|
||||
):
|
||||
if use_config:
|
||||
with tempfile.NamedTemporaryFile() as config:
|
||||
with open(config.name, "w") as f:
|
||||
cfg = f"""
|
||||
provider = "{provider}"
|
||||
token_command = "echo authtoken"
|
||||
root = "/myroot"
|
||||
"""
|
||||
|
||||
if not worktree_default:
|
||||
cfg += f"worktree = {str(worktree).lower()}\n"
|
||||
if force_ssh:
|
||||
cfg += f"force_ssh = true\n"
|
||||
if use_alternate_endpoint:
|
||||
cfg += f'api_url = "http://{ALTERNATE_DOMAIN}:5000/{provider}"\n'
|
||||
cfg += """
|
||||
[filters]
|
||||
groups = ["mygroup1"]\n
|
||||
"""
|
||||
|
||||
f.write(cfg)
|
||||
|
||||
args = ["repos", "find", "config", "--config", config.name]
|
||||
if not configtype_default:
|
||||
args += ["--format", configtype]
|
||||
cmd = grm(args)
|
||||
else:
|
||||
args = [
|
||||
"repos",
|
||||
"find",
|
||||
"remote",
|
||||
"--provider",
|
||||
provider,
|
||||
"--token-command",
|
||||
"echo authtoken",
|
||||
"--root",
|
||||
"/myroot",
|
||||
"--group",
|
||||
"mygroup1",
|
||||
]
|
||||
if not worktree_default:
|
||||
args += ["--worktree", str(worktree).lower()]
|
||||
if force_ssh:
|
||||
args += ["--force-ssh"]
|
||||
if use_alternate_endpoint:
|
||||
args += ["--api-url", f"http://{ALTERNATE_DOMAIN}:5000/{provider}"]
|
||||
|
||||
if not configtype_default:
|
||||
args += ["--format", configtype]
|
||||
cmd = grm(args)
|
||||
if use_alternate_endpoint and provider == "github":
|
||||
assert cmd.returncode != 0
|
||||
assert "overriding is not supported for github" in cmd.stderr.lower()
|
||||
return
|
||||
assert cmd.returncode == 0
|
||||
assert len(cmd.stderr) == 0
|
||||
|
||||
if configtype_default or configtype == "toml":
|
||||
output = toml.loads(cmd.stdout)
|
||||
elif configtype == "yaml":
|
||||
output = yaml.safe_load(cmd.stdout)
|
||||
else:
|
||||
raise NotImplementedError()
|
||||
|
||||
assert isinstance(output, dict)
|
||||
assert set(output.keys()) == {"trees"}
|
||||
assert isinstance(output["trees"], list)
|
||||
assert len(output["trees"]) == 1
|
||||
|
||||
assert set(output["trees"][0].keys()) == {"root", "repos"}
|
||||
assert isinstance(output["trees"][0]["repos"], list)
|
||||
assert len(output["trees"][0]["repos"]) == 5
|
||||
|
||||
for i in range(1, 6):
|
||||
repo = [r for r in output["trees"][0]["repos"] if r["name"] == f"myproject{i}"][
|
||||
0
|
||||
]
|
||||
assert repo["worktree_setup"] is (not worktree_default and worktree)
|
||||
assert isinstance(repo["remotes"], list)
|
||||
assert len(repo["remotes"]) == 1
|
||||
if force_ssh or i == 1:
|
||||
assert repo["remotes"][0]["name"] == provider
|
||||
assert (
|
||||
repo["remotes"][0]["url"]
|
||||
== f"ssh://git@example.com/mygroup1/myproject{i}.git"
|
||||
)
|
||||
assert repo["remotes"][0]["type"] == "ssh"
|
||||
else:
|
||||
assert repo["remotes"][0]["name"] == provider
|
||||
assert (
|
||||
repo["remotes"][0]["url"]
|
||||
== f"https://example.com/mygroup1/myproject{i}.git"
|
||||
)
|
||||
assert repo["remotes"][0]["type"] == "https"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("provider", PROVIDERS)
|
||||
@pytest.mark.parametrize("configtype_default", [False])
|
||||
@pytest.mark.parametrize("configtype", ["toml", "yaml"])
|
||||
@pytest.mark.parametrize("worktree_default", [True, False])
|
||||
@pytest.mark.parametrize("worktree", [True, False])
|
||||
@pytest.mark.parametrize("use_owner", [True, False])
|
||||
@pytest.mark.parametrize("force_ssh", [True, False])
|
||||
@pytest.mark.parametrize("use_alternate_endpoint", [True, False])
|
||||
@pytest.mark.parametrize("use_config", [True, False])
|
||||
def test_repos_find_remote_user_and_group(
|
||||
provider,
|
||||
configtype,
|
||||
configtype_default,
|
||||
worktree,
|
||||
worktree_default,
|
||||
use_owner,
|
||||
force_ssh,
|
||||
use_alternate_endpoint,
|
||||
use_config,
|
||||
):
|
||||
if use_config:
|
||||
with tempfile.NamedTemporaryFile() as config:
|
||||
with open(config.name, "w") as f:
|
||||
cfg = f"""
|
||||
provider = "{provider}"
|
||||
token_command = "echo authtoken"
|
||||
root = "/myroot"
|
||||
"""
|
||||
|
||||
if not worktree_default:
|
||||
cfg += f"worktree = {str(worktree).lower()}\n"
|
||||
if force_ssh:
|
||||
cfg += f"force_ssh = true\n"
|
||||
if use_alternate_endpoint:
|
||||
cfg += f'api_url = "http://{ALTERNATE_DOMAIN}:5000/{provider}"\n'
|
||||
cfg += """
|
||||
[filters]
|
||||
groups = ["mygroup1"]\n
|
||||
"""
|
||||
|
||||
if use_owner:
|
||||
cfg += "owner = true\n"
|
||||
else:
|
||||
cfg += 'users = ["myuser1"]\n'
|
||||
|
||||
f.write(cfg)
|
||||
|
||||
args = ["repos", "find", "config", "--config", config.name]
|
||||
if not configtype_default:
|
||||
args += ["--format", configtype]
|
||||
cmd = grm(args)
|
||||
else:
|
||||
args = [
|
||||
"repos",
|
||||
"find",
|
||||
"remote",
|
||||
"--provider",
|
||||
provider,
|
||||
"--token-command",
|
||||
"echo authtoken",
|
||||
"--root",
|
||||
"/myroot",
|
||||
"--group",
|
||||
"mygroup1",
|
||||
]
|
||||
if use_owner:
|
||||
args += ["--owner"]
|
||||
else:
|
||||
args += ["--user", "myuser1"]
|
||||
if not worktree_default:
|
||||
args += ["--worktree", str(worktree).lower()]
|
||||
if force_ssh:
|
||||
args += ["--force-ssh"]
|
||||
if use_alternate_endpoint:
|
||||
args += ["--api-url", f"http://{ALTERNATE_DOMAIN}:5000/{provider}"]
|
||||
|
||||
if not configtype_default:
|
||||
args += ["--format", configtype]
|
||||
cmd = grm(args)
|
||||
if use_alternate_endpoint and provider == "github":
|
||||
assert cmd.returncode != 0
|
||||
assert "overriding is not supported for github" in cmd.stderr.lower()
|
||||
return
|
||||
assert cmd.returncode == 0
|
||||
assert len(cmd.stderr) == 0
|
||||
|
||||
if configtype_default or configtype == "toml":
|
||||
output = toml.loads(cmd.stdout)
|
||||
elif configtype == "yaml":
|
||||
output = yaml.safe_load(cmd.stdout)
|
||||
else:
|
||||
raise NotImplementedError()
|
||||
|
||||
assert isinstance(output, dict)
|
||||
assert set(output.keys()) == {"trees"}
|
||||
assert isinstance(output["trees"], list)
|
||||
assert len(output["trees"]) == 2
|
||||
|
||||
user_namespace = [t for t in output["trees"] if t["root"] == "/myroot/myuser1"][0]
|
||||
|
||||
assert set(user_namespace.keys()) == {"root", "repos"}
|
||||
assert isinstance(user_namespace["repos"], list)
|
||||
assert len(user_namespace["repos"]) == 5
|
||||
|
||||
for i in range(1, 6):
|
||||
repo = [r for r in user_namespace["repos"] if r["name"] == f"myproject{i}"][0]
|
||||
assert repo["worktree_setup"] is (not worktree_default and worktree)
|
||||
assert isinstance(repo["remotes"], list)
|
||||
assert len(repo["remotes"]) == 1
|
||||
assert repo["remotes"][0]["name"] == provider
|
||||
if force_ssh or i == 1:
|
||||
assert (
|
||||
repo["remotes"][0]["url"]
|
||||
== f"ssh://git@example.com/myuser1/myproject{i}.git"
|
||||
)
|
||||
assert repo["remotes"][0]["type"] == "ssh"
|
||||
else:
|
||||
assert (
|
||||
repo["remotes"][0]["url"]
|
||||
== f"https://example.com/myuser1/myproject{i}.git"
|
||||
)
|
||||
assert repo["remotes"][0]["type"] == "https"
|
||||
|
||||
group_namespace = [t for t in output["trees"] if t["root"] == "/myroot/mygroup1"][0]
|
||||
|
||||
assert set(group_namespace.keys()) == {"root", "repos"}
|
||||
assert isinstance(group_namespace["repos"], list)
|
||||
assert len(group_namespace["repos"]) == 5
|
||||
|
||||
for i in range(1, 6):
|
||||
repo = [r for r in group_namespace["repos"] if r["name"] == f"myproject{i}"][0]
|
||||
assert repo["worktree_setup"] is (not worktree_default and worktree)
|
||||
assert isinstance(repo["remotes"], list)
|
||||
assert len(repo["remotes"]) == 1
|
||||
assert repo["remotes"][0]["name"] == provider
|
||||
if force_ssh or i == 1:
|
||||
assert (
|
||||
repo["remotes"][0]["url"]
|
||||
== f"ssh://git@example.com/mygroup1/myproject{i}.git"
|
||||
)
|
||||
assert repo["remotes"][0]["type"] == "ssh"
|
||||
else:
|
||||
assert (
|
||||
repo["remotes"][0]["url"]
|
||||
== f"https://example.com/mygroup1/myproject{i}.git"
|
||||
)
|
||||
assert repo["remotes"][0]["type"] == "https"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("provider", PROVIDERS)
|
||||
@pytest.mark.parametrize("configtype_default", [False])
|
||||
@pytest.mark.parametrize("configtype", ["toml", "yaml"])
|
||||
@pytest.mark.parametrize("worktree_default", [True, False])
|
||||
@pytest.mark.parametrize("worktree", [True, False])
|
||||
@pytest.mark.parametrize("with_user_filter", [True, False])
|
||||
@pytest.mark.parametrize("with_group_filter", [True, False])
|
||||
@pytest.mark.parametrize("force_ssh", [True, False])
|
||||
@pytest.mark.parametrize("use_alternate_endpoint", [True, False])
|
||||
@pytest.mark.parametrize("use_config", [True, False])
|
||||
def test_repos_find_remote_owner(
|
||||
provider,
|
||||
configtype,
|
||||
configtype_default,
|
||||
worktree,
|
||||
worktree_default,
|
||||
with_user_filter,
|
||||
with_group_filter,
|
||||
force_ssh,
|
||||
use_alternate_endpoint,
|
||||
use_config,
|
||||
):
|
||||
if use_config:
|
||||
with tempfile.NamedTemporaryFile() as config:
|
||||
with open(config.name, "w") as f:
|
||||
cfg = f"""
|
||||
provider = "{provider}"
|
||||
token_command = "echo authtoken"
|
||||
root = "/myroot"
|
||||
"""
|
||||
|
||||
if not worktree_default:
|
||||
cfg += f"worktree = {str(worktree).lower()}\n"
|
||||
if force_ssh:
|
||||
cfg += f"force_ssh = true\n"
|
||||
if use_alternate_endpoint:
|
||||
cfg += f'api_url = "http://{ALTERNATE_DOMAIN}:5000/{provider}"\n'
|
||||
cfg += """
|
||||
[filters]
|
||||
access = true\n
|
||||
"""
|
||||
|
||||
if with_user_filter:
|
||||
cfg += 'users = ["myuser1"]\n'
|
||||
if with_group_filter:
|
||||
cfg += 'groups = ["mygroup1"]\n'
|
||||
|
||||
f.write(cfg)
|
||||
|
||||
args = ["repos", "find", "config", "--config", config.name]
|
||||
if not configtype_default:
|
||||
args += ["--format", configtype]
|
||||
cmd = grm(args)
|
||||
|
||||
else:
|
||||
args = [
|
||||
"repos",
|
||||
"find",
|
||||
"remote",
|
||||
"--provider",
|
||||
provider,
|
||||
"--token-command",
|
||||
"echo authtoken",
|
||||
"--root",
|
||||
"/myroot",
|
||||
"--access",
|
||||
]
|
||||
if not worktree_default:
|
||||
args += ["--worktree", str(worktree).lower()]
|
||||
if with_user_filter:
|
||||
args += ["--user", "myuser1"]
|
||||
if with_group_filter:
|
||||
args += ["--group", "mygroup1"]
|
||||
if force_ssh:
|
||||
args += ["--force-ssh"]
|
||||
if use_alternate_endpoint:
|
||||
args += ["--api-url", f"http://{ALTERNATE_DOMAIN}:5000/{provider}"]
|
||||
|
||||
if not configtype_default:
|
||||
args += ["--format", configtype]
|
||||
cmd = grm(args)
|
||||
if use_alternate_endpoint and provider == "github":
|
||||
assert cmd.returncode != 0
|
||||
assert "overriding is not supported for github" in cmd.stderr.lower()
|
||||
return
|
||||
assert cmd.returncode == 0
|
||||
assert len(cmd.stderr) == 0
|
||||
|
||||
if configtype_default or configtype == "toml":
|
||||
output = toml.loads(cmd.stdout)
|
||||
elif configtype == "yaml":
|
||||
output = yaml.safe_load(cmd.stdout)
|
||||
else:
|
||||
raise NotImplementedError()
|
||||
|
||||
assert isinstance(output, dict)
|
||||
assert set(output.keys()) == {"trees"}
|
||||
assert isinstance(output["trees"], list)
|
||||
assert len(output["trees"]) == 4
|
||||
|
||||
user_namespace_1 = [t for t in output["trees"] if t["root"] == "/myroot/myuser1"][0]
|
||||
|
||||
assert set(user_namespace_1.keys()) == {"root", "repos"}
|
||||
assert isinstance(user_namespace_1["repos"], list)
|
||||
|
||||
if with_user_filter:
|
||||
assert len(user_namespace_1["repos"]) == 5
|
||||
|
||||
for i in range(1, 6):
|
||||
repo = [
|
||||
r for r in user_namespace_1["repos"] if r["name"] == f"myproject{i}"
|
||||
][0]
|
||||
assert repo["worktree_setup"] is (not worktree_default and worktree)
|
||||
assert isinstance(repo["remotes"], list)
|
||||
assert len(repo["remotes"]) == 1
|
||||
assert repo["remotes"][0]["name"] == provider
|
||||
if force_ssh or i == 1:
|
||||
assert (
|
||||
repo["remotes"][0]["url"]
|
||||
== f"ssh://git@example.com/myuser1/myproject{i}.git"
|
||||
)
|
||||
assert repo["remotes"][0]["type"] == "ssh"
|
||||
else:
|
||||
assert (
|
||||
repo["remotes"][0]["url"]
|
||||
== f"https://example.com/myuser1/myproject{i}.git"
|
||||
)
|
||||
assert repo["remotes"][0]["type"] == "https"
|
||||
else:
|
||||
assert len(user_namespace_1["repos"]) == 2
|
||||
|
||||
for i in range(1, 3):
|
||||
repo = [
|
||||
r for r in user_namespace_1["repos"] if r["name"] == f"myproject{i}"
|
||||
][0]
|
||||
assert repo["worktree_setup"] is (not worktree_default and worktree)
|
||||
assert isinstance(repo["remotes"], list)
|
||||
assert len(repo["remotes"]) == 1
|
||||
assert repo["remotes"][0]["name"] == provider
|
||||
if force_ssh or i == 1:
|
||||
assert (
|
||||
repo["remotes"][0]["url"]
|
||||
== f"ssh://git@example.com/myuser1/myproject{i}.git"
|
||||
)
|
||||
assert repo["remotes"][0]["type"] == "ssh"
|
||||
else:
|
||||
assert (
|
||||
repo["remotes"][0]["url"]
|
||||
== f"https://example.com/myuser1/myproject{i}.git"
|
||||
)
|
||||
assert repo["remotes"][0]["type"] == "https"
|
||||
|
||||
user_namespace_2 = [t for t in output["trees"] if t["root"] == "/myroot/myuser2"][0]
|
||||
|
||||
assert set(user_namespace_2.keys()) == {"root", "repos"}
|
||||
assert isinstance(user_namespace_2["repos"], list)
|
||||
assert len(user_namespace_2["repos"]) == 1
|
||||
|
||||
repo = user_namespace_2["repos"][0]
|
||||
assert repo["worktree_setup"] is (not worktree_default and worktree)
|
||||
assert isinstance(repo["remotes"], list)
|
||||
assert len(repo["remotes"]) == 1
|
||||
assert repo["remotes"][0]["name"] == provider
|
||||
if force_ssh:
|
||||
assert (
|
||||
repo["remotes"][0]["url"] == f"ssh://git@example.com/myuser2/myproject3.git"
|
||||
)
|
||||
assert repo["remotes"][0]["type"] == "ssh"
|
||||
else:
|
||||
assert (
|
||||
repo["remotes"][0]["url"] == f"https://example.com/myuser2/myproject3.git"
|
||||
)
|
||||
assert repo["remotes"][0]["type"] == "https"
|
||||
|
||||
group_namespace_1 = [t for t in output["trees"] if t["root"] == "/myroot/mygroup1"][
|
||||
0
|
||||
]
|
||||
|
||||
assert set(group_namespace_1.keys()) == {"root", "repos"}
|
||||
assert isinstance(group_namespace_1["repos"], list)
|
||||
|
||||
if with_group_filter:
|
||||
assert len(group_namespace_1["repos"]) == 5
|
||||
|
||||
for i in range(1, 6):
|
||||
repo = [
|
||||
r for r in group_namespace_1["repos"] if r["name"] == f"myproject{i}"
|
||||
][0]
|
||||
assert repo["worktree_setup"] is (not worktree_default and worktree)
|
||||
assert isinstance(repo["remotes"], list)
|
||||
assert len(repo["remotes"]) == 1
|
||||
assert repo["remotes"][0]["name"] == provider
|
||||
if force_ssh or i == 1:
|
||||
assert (
|
||||
repo["remotes"][0]["url"]
|
||||
== f"ssh://git@example.com/mygroup1/myproject{i}.git"
|
||||
)
|
||||
assert repo["remotes"][0]["type"] == "ssh"
|
||||
else:
|
||||
assert (
|
||||
repo["remotes"][0]["url"]
|
||||
== f"https://example.com/mygroup1/myproject{i}.git"
|
||||
)
|
||||
assert repo["remotes"][0]["type"] == "https"
|
||||
else:
|
||||
assert len(group_namespace_1["repos"]) == 1
|
||||
|
||||
repo = group_namespace_1["repos"][0]
|
||||
assert repo["worktree_setup"] is (not worktree_default and worktree)
|
||||
assert isinstance(repo["remotes"], list)
|
||||
assert len(repo["remotes"]) == 1
|
||||
assert repo["remotes"][0]["name"] == provider
|
||||
if force_ssh:
|
||||
assert (
|
||||
repo["remotes"][0]["url"]
|
||||
== f"ssh://git@example.com/mygroup1/myproject4.git"
|
||||
)
|
||||
assert repo["remotes"][0]["type"] == "ssh"
|
||||
else:
|
||||
assert (
|
||||
repo["remotes"][0]["url"]
|
||||
== f"https://example.com/mygroup1/myproject4.git"
|
||||
)
|
||||
assert repo["remotes"][0]["type"] == "https"
|
||||
|
||||
group_namespace_2 = [t for t in output["trees"] if t["root"] == "/myroot/mygroup2"][
|
||||
0
|
||||
]
|
||||
|
||||
assert set(group_namespace_2.keys()) == {"root", "repos"}
|
||||
assert isinstance(group_namespace_2["repos"], list)
|
||||
assert len(group_namespace_2["repos"]) == 1
|
||||
|
||||
repo = group_namespace_2["repos"][0]
|
||||
assert repo["worktree_setup"] is (not worktree_default and worktree)
|
||||
assert isinstance(repo["remotes"], list)
|
||||
assert len(repo["remotes"]) == 1
|
||||
assert repo["remotes"][0]["name"] == provider
|
||||
if force_ssh:
|
||||
assert (
|
||||
repo["remotes"][0]["url"]
|
||||
== f"ssh://git@example.com/mygroup2/myproject5.git"
|
||||
)
|
||||
assert repo["remotes"][0]["type"] == "ssh"
|
||||
else:
|
||||
assert (
|
||||
repo["remotes"][0]["url"] == f"https://example.com/mygroup2/myproject5.git"
|
||||
)
|
||||
assert repo["remotes"][0]["type"] == "https"
|
||||
@@ -154,7 +154,7 @@ def test_repos_sync_config_is_valid_symlink(configtype):
|
||||
|
||||
subprocess.run(["cat", config.name])
|
||||
|
||||
cmd = grm(["repos", "sync", "--config", config_symlink])
|
||||
cmd = grm(["repos", "sync", "config", "--config", config_symlink])
|
||||
assert cmd.returncode == 0
|
||||
|
||||
git_dir = os.path.join(target, "test")
|
||||
@@ -174,7 +174,7 @@ def test_repos_sync_config_is_invalid_symlink():
|
||||
config_symlink = os.path.join(config_dir, "cfglink")
|
||||
os.symlink(nonexistent_dir, config_symlink)
|
||||
|
||||
cmd = grm(["repos", "sync", "--config", config_symlink])
|
||||
cmd = grm(["repos", "sync", "config", "--config", config_symlink])
|
||||
|
||||
assert cmd.returncode != 0
|
||||
assert len(cmd.stdout) == 0
|
||||
@@ -185,7 +185,7 @@ def test_repos_sync_config_is_invalid_symlink():
|
||||
|
||||
def test_repos_sync_config_is_directory():
|
||||
with tempfile.TemporaryDirectory() as config:
|
||||
cmd = grm(["repos", "sync", "--config", config])
|
||||
cmd = grm(["repos", "sync", "config", "--config", config])
|
||||
|
||||
assert cmd.returncode != 0
|
||||
assert len(cmd.stdout) == 0
|
||||
@@ -197,12 +197,11 @@ def test_repos_sync_config_is_unreadable():
|
||||
config_path = os.path.join(config_dir, "cfg")
|
||||
open(config_path, "w")
|
||||
os.chmod(config_path, 0o0000)
|
||||
cmd = grm(["repos", "sync", "--config", config_path])
|
||||
cmd = grm(["repos", "sync", "config", "--config", config_path])
|
||||
|
||||
assert os.path.exists(config_path)
|
||||
assert cmd.returncode != 0
|
||||
assert len(cmd.stdout) == 0
|
||||
assert "permission denied" in cmd.stderr.lower()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("configtype", ["toml", "yaml"])
|
||||
@@ -213,7 +212,7 @@ def test_repos_sync_unmanaged_repos(configtype):
|
||||
with open(config.name, "w") as f:
|
||||
f.write(templates["repo_simple"][configtype].format(root=root))
|
||||
|
||||
cmd = grm(["repos", "sync", "--config", config.name])
|
||||
cmd = grm(["repos", "sync", "config", "--config", config.name])
|
||||
assert cmd.returncode == 0
|
||||
|
||||
git_dir = os.path.join(root, "test")
|
||||
@@ -232,7 +231,7 @@ def test_repos_sync_root_is_file(configtype):
|
||||
with open(config.name, "w") as f:
|
||||
f.write(templates["repo_simple"][configtype].format(root=target.name))
|
||||
|
||||
cmd = grm(["repos", "sync", "--config", config.name])
|
||||
cmd = grm(["repos", "sync", "config", "--config", config.name])
|
||||
assert cmd.returncode != 0
|
||||
assert len(cmd.stdout) == 0
|
||||
assert "not a directory" in cmd.stderr.lower()
|
||||
@@ -251,7 +250,7 @@ def test_repos_sync_normal_clone(configtype):
|
||||
)
|
||||
)
|
||||
|
||||
cmd = grm(["repos", "sync", "--config", config.name])
|
||||
cmd = grm(["repos", "sync", "config", "--config", config.name])
|
||||
assert cmd.returncode == 0
|
||||
|
||||
git_dir = os.path.join(target, "test")
|
||||
@@ -283,7 +282,7 @@ def test_repos_sync_normal_init(configtype):
|
||||
with open(config.name, "w") as f:
|
||||
f.write(templates["repo_simple"][configtype].format(root=target))
|
||||
|
||||
cmd = grm(["repos", "sync", "--config", config.name])
|
||||
cmd = grm(["repos", "sync", "config", "--config", config.name])
|
||||
assert cmd.returncode == 0
|
||||
|
||||
git_dir = os.path.join(target, "test")
|
||||
@@ -309,7 +308,7 @@ def test_repos_sync_normal_add_remote(configtype):
|
||||
)
|
||||
)
|
||||
|
||||
cmd = grm(["repos", "sync", "--config", config.name])
|
||||
cmd = grm(["repos", "sync", "config", "--config", config.name])
|
||||
assert cmd.returncode == 0
|
||||
|
||||
git_dir = os.path.join(target, "test")
|
||||
@@ -329,7 +328,7 @@ def test_repos_sync_normal_add_remote(configtype):
|
||||
)
|
||||
)
|
||||
|
||||
cmd = grm(["repos", "sync", "--config", config.name])
|
||||
cmd = grm(["repos", "sync", "config", "--config", config.name])
|
||||
assert cmd.returncode == 0
|
||||
with git.Repo(git_dir) as repo:
|
||||
assert set([str(r) for r in repo.remotes]) == {
|
||||
@@ -359,7 +358,7 @@ def test_repos_sync_normal_remove_remote(configtype):
|
||||
)
|
||||
)
|
||||
|
||||
cmd = grm(["repos", "sync", "--config", config.name])
|
||||
cmd = grm(["repos", "sync", "config", "--config", config.name])
|
||||
assert cmd.returncode == 0
|
||||
|
||||
git_dir = os.path.join(target, "test")
|
||||
@@ -382,7 +381,7 @@ def test_repos_sync_normal_remove_remote(configtype):
|
||||
)
|
||||
)
|
||||
|
||||
cmd = grm(["repos", "sync", "--config", config.name])
|
||||
cmd = grm(["repos", "sync", "config", "--config", config.name])
|
||||
assert cmd.returncode == 0
|
||||
shell(f"cd {git_dir} && git remote -v")
|
||||
with git.Repo(git_dir) as repo:
|
||||
@@ -424,7 +423,7 @@ def test_repos_sync_normal_change_remote_url(configtype):
|
||||
)
|
||||
)
|
||||
|
||||
cmd = grm(["repos", "sync", "--config", config.name])
|
||||
cmd = grm(["repos", "sync", "config", "--config", config.name])
|
||||
assert cmd.returncode == 0
|
||||
|
||||
git_dir = os.path.join(target, "test")
|
||||
@@ -444,7 +443,7 @@ def test_repos_sync_normal_change_remote_url(configtype):
|
||||
)
|
||||
)
|
||||
|
||||
cmd = grm(["repos", "sync", "--config", config.name])
|
||||
cmd = grm(["repos", "sync", "config", "--config", config.name])
|
||||
assert cmd.returncode == 0
|
||||
with git.Repo(git_dir) as repo:
|
||||
assert set([str(r) for r in repo.remotes]) == {"origin"}
|
||||
@@ -467,7 +466,7 @@ def test_repos_sync_normal_change_remote_name(configtype):
|
||||
)
|
||||
)
|
||||
|
||||
cmd = grm(["repos", "sync", "--config", config.name])
|
||||
cmd = grm(["repos", "sync", "config", "--config", config.name])
|
||||
assert cmd.returncode == 0
|
||||
|
||||
git_dir = os.path.join(target, "test")
|
||||
@@ -487,7 +486,7 @@ def test_repos_sync_normal_change_remote_name(configtype):
|
||||
)
|
||||
)
|
||||
|
||||
cmd = grm(["repos", "sync", "--config", config.name])
|
||||
cmd = grm(["repos", "sync", "config", "--config", config.name])
|
||||
assert cmd.returncode == 0
|
||||
with git.Repo(git_dir) as repo:
|
||||
# See the note in `test_repos_sync_normal_remove_remote()`
|
||||
@@ -512,7 +511,7 @@ def test_repos_sync_worktree_clone(configtype):
|
||||
)
|
||||
)
|
||||
|
||||
cmd = grm(["repos", "sync", "--config", config.name])
|
||||
cmd = grm(["repos", "sync", "config", "--config", config.name])
|
||||
assert cmd.returncode == 0
|
||||
|
||||
worktree_dir = f"{target}/test"
|
||||
@@ -538,7 +537,7 @@ def test_repos_sync_worktree_init(configtype):
|
||||
templates["worktree_repo_simple"][configtype].format(root=target)
|
||||
)
|
||||
|
||||
cmd = grm(["repos", "sync", "--config", config.name])
|
||||
cmd = grm(["repos", "sync", "config", "--config", config.name])
|
||||
assert cmd.returncode == 0
|
||||
|
||||
worktree_dir = f"{target}/test"
|
||||
@@ -573,7 +572,7 @@ def test_repos_sync_invalid_syntax(configtype):
|
||||
)
|
||||
else:
|
||||
raise NotImplementedError()
|
||||
cmd = grm(["repos", "sync", "--config", config.name])
|
||||
cmd = grm(["repos", "sync", "config", "--config", config.name])
|
||||
assert cmd.returncode != 0
|
||||
|
||||
|
||||
@@ -590,11 +589,11 @@ def test_repos_sync_unchanged(configtype):
|
||||
)
|
||||
)
|
||||
|
||||
cmd = grm(["repos", "sync", "--config", config.name])
|
||||
cmd = grm(["repos", "sync", "config", "--config", config.name])
|
||||
assert cmd.returncode == 0
|
||||
|
||||
before = checksum_directory(target)
|
||||
cmd = grm(["repos", "sync", "--config", config.name])
|
||||
cmd = grm(["repos", "sync", "config", "--config", config.name])
|
||||
after = checksum_directory(target)
|
||||
assert cmd.returncode == 0
|
||||
|
||||
@@ -614,7 +613,7 @@ def test_repos_sync_normal_change_to_worktree(configtype):
|
||||
)
|
||||
)
|
||||
|
||||
cmd = grm(["repos", "sync", "--config", config.name])
|
||||
cmd = grm(["repos", "sync", "config", "--config", config.name])
|
||||
assert cmd.returncode == 0
|
||||
|
||||
git_dir = os.path.join(target, "test")
|
||||
@@ -626,7 +625,7 @@ def test_repos_sync_normal_change_to_worktree(configtype):
|
||||
)
|
||||
)
|
||||
|
||||
cmd = grm(["repos", "sync", "--config", config.name])
|
||||
cmd = grm(["repos", "sync", "config", "--config", config.name])
|
||||
assert cmd.returncode != 0
|
||||
assert "already exists" in cmd.stderr
|
||||
assert "not using a worktree setup" in cmd.stderr
|
||||
@@ -645,7 +644,7 @@ def test_repos_sync_worktree_change_to_normal(configtype):
|
||||
)
|
||||
)
|
||||
|
||||
cmd = grm(["repos", "sync", "--config", config.name])
|
||||
cmd = grm(["repos", "sync", "config", "--config", config.name])
|
||||
assert cmd.returncode == 0
|
||||
|
||||
git_dir = os.path.join(target, "test")
|
||||
@@ -657,7 +656,7 @@ def test_repos_sync_worktree_change_to_normal(configtype):
|
||||
)
|
||||
)
|
||||
|
||||
cmd = grm(["repos", "sync", "--config", config.name])
|
||||
cmd = grm(["repos", "sync", "config", "--config", config.name])
|
||||
assert cmd.returncode != 0
|
||||
assert "already exists" in cmd.stderr
|
||||
assert "using a worktree setup" in cmd.stderr
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -o nounset
|
||||
set -o errexit
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
source ./venv/bin/activate
|
||||
|
||||
pip --disable-pip-version-check install -r ./requirements.txt
|
||||
|
||||
pip3 list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | while read -r package ; do
|
||||
[[ "$package" == "pip" ]] && continue
|
||||
[[ "$package" == "setuptools" ]] && continue
|
||||
pip install --upgrade "${package}"
|
||||
version="$(pip show "${package}" | grep '^Version' | cut -d ' ' -f 2)"
|
||||
message="e2e_tests/pip: Update ${package} to ${version}"
|
||||
pip freeze | grep -v '^pkg_resources' > requirements.txt
|
||||
git add ./requirements.txt
|
||||
git commit --message "${message}"
|
||||
done
|
||||
Reference in New Issue
Block a user