Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

test(functional): simplify token creation#2186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
JohnVillalovos merged 1 commit intomainfromtest/simplify-docker
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 2 additions & 25 deletionstests/functional/conftest.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -50,27 +50,6 @@ def reset_gitlab(gl: gitlab.Gitlab) -> None:
helpers.safe_delete(user, hard_delete=True)


def set_token(container, fixture_dir):
logging.info("Creating API token.")
set_token_rb = fixture_dir / "set_token.rb"

with open(set_token_rb, "r", encoding="utf-8") as f:
set_token_command = f.read().strip()

rails_command = [
"docker",
"exec",
container,
"gitlab-rails",
"runner",
set_token_command,
]
output = check_output(rails_command).decode().strip()
logging.info("Finished creating API token.")

return output


def pytest_report_collectionfinish(config, startdir, items):
return [
"",
Expand DownExpand Up@@ -157,7 +136,7 @@ def _wait(timeout=30, step=0.5):


@pytest.fixture(scope="session")
def gitlab_config(check_is_alive, docker_ip, docker_services, temp_dir, fixture_dir):
def gitlab_config(check_is_alive, docker_ip, docker_services, temp_dir):
config_file = temp_dir / "python-gitlab.cfg"
port = docker_services.port_for("gitlab", 80)

Expand All@@ -174,15 +153,13 @@ def gitlab_config(check_is_alive, docker_ip, docker_services, temp_dir, fixture_
f"GitLab container is now ready after {minutes} minute(s), {seconds} seconds"
)

token = set_token("gitlab-test", fixture_dir=fixture_dir)

config = f"""[global]
default = local
timeout = 60

[local]
url = http://{docker_ip}:{port}
private_token ={token}
private_token =python-gitlab-token
api_version = 4"""

with open(config_file, "w", encoding="utf-8") as f:
Expand Down
6 changes: 6 additions & 0 deletionstests/functional/fixtures/docker-compose.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,6 +31,12 @@ services:
gitlab_exporter['enable'] = false
grafana['enable'] = false
letsencrypt['enable'] = false
entrypoint:
- /bin/sh
- -c
- chmod 644 /opt/gitlab/embedded/service/gitlab-rails/db/fixtures/production/* && /assets/wrapper
volumes:
- ${PWD}/tests/functional/fixtures/set_token.rb:/opt/gitlab/embedded/service/gitlab-rails/db/fixtures/production/003_set_token.rb
ports:
- '8080:80'
- '2222:22'
Expand Down
2 changes: 1 addition & 1 deletiontox.ini
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,7 @@ skip_missing_interpreters = True
envlist = py310,py39,py38,py37,flake8,black,twine-check,mypy,isort,cz,pylint

[testenv]
passenv = GITLAB_IMAGE GITLAB_TAG PY_COLORS NO_COLOR FORCE_COLOR DOCKER_HOST
passenv = GITLAB_IMAGE GITLAB_TAG PY_COLORS NO_COLOR FORCE_COLOR DOCKER_HOST PWD
setenv = VIRTUAL_ENV={envdir}
whitelist_externals = true
usedevelop = True
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp