Skip to content

Commit 21fcef6

Browse files
committed
fix: use programmatic dates for expires_at in tokens tests
1 parent 6c96d0f commit 21fcef6

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

tests/functional/api/test_deploy_tokens.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
from datetime import date
2+
3+
14
def test_project_deploy_tokens(gl, project):
5+
today = date.today().isoformat()
26
deploy_token = project.deploytokens.create(
37
{
48
"name": "foo",
59
"username": "bar",
6-
"expires_at": "2022-01-01",
10+
"expires_at": today,
711
"scopes": ["read_registry"],
812
}
913
)
@@ -12,7 +16,7 @@ def test_project_deploy_tokens(gl, project):
1216

1317
deploy_token = project.deploytokens.get(deploy_token.id)
1418
assert deploy_token.name == "foo"
15-
assert deploy_token.expires_at == "2022-01-01T00:00:00.000Z"
19+
assert deploy_token.expires_at == today + "T00:00:00.000Z"
1620
assert deploy_token.scopes == ["read_registry"]
1721
assert deploy_token.username == "bar"
1822

tests/functional/cli/test_cli_v4.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import time
3+
from datetime import date
34

45

56
def test_create_project(gitlab_cli):
@@ -590,7 +591,7 @@ def test_create_project_with_values_at_prefixed(gitlab_cli, tmpdir):
590591
def test_create_project_deploy_token(gitlab_cli, project):
591592
name = "project-token"
592593
username = "root"
593-
expires_at = "2021-09-09"
594+
expires_at = (date.today().isoformat(),)
594595
scopes = "read_registry"
595596

596597
cmd = [
@@ -666,7 +667,7 @@ def test_delete_project_deploy_token(gitlab_cli, deploy_token):
666667
def test_create_group_deploy_token(gitlab_cli, group):
667668
name = "group-token"
668669
username = "root"
669-
expires_at = "2021-09-09"
670+
expires_at = (date.today().isoformat(),)
670671
scopes = "read_registry"
671672

672673
cmd = [

tests/functional/conftest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import tempfile
55
import time
66
import uuid
7+
from datetime import date
78
from subprocess import check_output
89
from typing import Optional
910

@@ -601,7 +602,7 @@ def deploy_token(project):
601602
data = {
602603
"name": f"token-{_id}",
603604
"username": "root",
604-
"expires_at": "2021-09-09",
605+
"expires_at": date.today().isoformat(),
605606
"scopes": "read_registry",
606607
}
607608

@@ -615,7 +616,7 @@ def group_deploy_token(group):
615616
data = {
616617
"name": f"group-token-{_id}",
617618
"username": "root",
618-
"expires_at": "2021-09-09",
619+
"expires_at": date.today().isoformat(),
619620
"scopes": "read_registry",
620621
}
621622

0 commit comments

Comments
 (0)