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

Appearance settings

Commit 4b798fc

Browse filesBrowse files
nejchJohnVillalovos
authored andcommitted
chore: revert "test(functional): simplify token creation"
This reverts commit 67ab24f.
1 parent b661003 commit 4b798fc
Copy full SHA for 4b798fc

File tree

Expand file treeCollapse file tree

2 files changed

+26
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+26
-4
lines changed
Open diff view settings
Collapse file

‎tests/functional/conftest.py‎

Copy file name to clipboardExpand all lines: tests/functional/conftest.py
+25-2Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,27 @@ def reset_gitlab(gl: gitlab.Gitlab) -> None:
6060
helpers.safe_delete(user, hard_delete=True)
6161

6262

63+
def set_token(container, fixture_dir):
64+
logging.info("Creating API token.")
65+
set_token_rb = fixture_dir / "set_token.rb"
66+
67+
with open(set_token_rb, "r", encoding="utf-8") as f:
68+
set_token_command = f.read().strip()
69+
70+
rails_command = [
71+
"docker",
72+
"exec",
73+
container,
74+
"gitlab-rails",
75+
"runner",
76+
set_token_command,
77+
]
78+
output = check_output(rails_command).decode().strip()
79+
logging.info("Finished creating API token.")
80+
81+
return output
82+
83+
6384
def pytest_report_collectionfinish(config, startdir, items):
6485
return [
6586
"",
@@ -146,7 +167,7 @@ def _wait(timeout=30, step=0.5):
146167

147168

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

@@ -163,13 +184,15 @@ def gitlab_config(check_is_alive, docker_ip, docker_services, temp_dir):
163184
f"GitLab container is now ready after {minutes} minute(s), {seconds} seconds"
164185
)
165186

187+
token = set_token("gitlab-test", fixture_dir=fixture_dir)
188+
166189
config = f"""[global]
167190
default = local
168191
timeout = 60
169192
170193
[local]
171194
url = http://{docker_ip}:{port}
172-
private_token = python-gitlab-token
195+
private_token = {token}
173196
api_version = 4"""
174197

175198
with open(config_file, "w", encoding="utf-8") as f:
Collapse file

‎tests/functional/fixtures/docker-compose.yml‎

Copy file name to clipboardExpand all lines: tests/functional/fixtures/docker-compose.yml
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ services:
3535
entrypoint:
3636
- /bin/sh
3737
- -c
38-
- ruby /create_license.rb && chmod 644 /opt/gitlab/embedded/service/gitlab-rails/db/fixtures/production/* && /assets/wrapper
38+
- ruby /create_license.rb && /assets/wrapper
3939
volumes:
40-
- ${PWD}/tests/functional/fixtures/set_token.rb:/opt/gitlab/embedded/service/gitlab-rails/db/fixtures/production/003_set_token.rb
4140
- ${PWD}/tests/functional/fixtures/create_license.rb:/create_license.rb
4241
ports:
4342
- '8080:80'

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.