-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest_integrations_github.py
More file actions
85 lines (69 loc) · 4.13 KB
/
Copy pathtest_integrations_github.py
File metadata and controls
85 lines (69 loc) · 4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
from tests.helpers.utils import *
# Since responses are all mocked and no data validation is done by the CLI --
# we let the API handle validation -- we don't need valid input files.
def _dummy_file(tmp_path):
f = tmp_path / "test_integrations_github_add.json"
f.write_text("foobar")
return f
@responses.activate
def test_integrations_github_add():
responses.add(responses.POST, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configurations/app", json={}, status=200)
cli(["integrations", "github", "add", "-a", "myAlias", "-h", "my.host.com", "--api-key", "123456", "-i"])
@responses.activate
def test_integrations_github_delete():
responses.add(responses.DELETE, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configurations/app/test", status=200)
cli(["integrations", "github", "delete", "-a", "test"])
@responses.activate
def test_integrations_github_delete_all():
responses.add(responses.DELETE, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configurations", status=200)
cli(["integrations", "github", "delete-all"])
@responses.activate
def test_integrations_github_get():
responses.add(responses.GET, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configurations/app/test", json={}, status=200)
cli(["integrations", "github", "get", "-a", "test"])
@responses.activate
def test_integrations_github_list():
responses.add(responses.GET, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configurations", json={}, status=200)
cli(["integrations", "github", "list"])
@responses.activate
def test_integrations_github_get_default():
responses.add(responses.GET, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/default-configuration", json={}, status=200)
cli(["integrations", "github", "get-default"])
@responses.activate
def test_integrations_github_update():
responses.add(responses.PUT, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configurations/app/test", json={}, status=200)
cli(["integrations", "github", "update", "-a", "test", "-i"])
@responses.activate
def test_integrations_github_validate():
responses.add(responses.POST, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configurations/validate/test", json={}, status=200)
cli(["integrations", "github", "validate", "-a", "test"])
@responses.activate
def test_integrations_github_validate_all():
responses.add(responses.POST, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configurations/validate", json={}, status=200)
cli(["integrations", "github", "validate-all"])
@responses.activate
def test_integrations_github_add_personal():
responses.add(responses.POST, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configurations/personal", json={}, status=200)
cli(["integrations", "github", "add-personal", "-a", "myAlias", "-h", "my.host.com", "--access-token", "123456", "-i"])
@responses.activate
def test_integrations_github_update_personal():
responses.add(responses.PUT, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configurations/personal/test", json={}, status=200)
cli(["integrations", "github", "update-personal", "-a", "test", "-i"])
@responses.activate
def test_integrations_github_get_personal():
responses.add(responses.GET, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configurations/personal/test", json={}, status=200)
cli(["integrations", "github", "get-personal", "-a", "test"])
@responses.activate
def test_integrations_github_delete_personal():
responses.add(responses.DELETE, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configurations/personal/test", status=200)
cli(["integrations", "github", "delete-personal", "-a", "test"])
@responses.activate
def test_integrations_github_add_file_with_flags_error(tmp_path):
f = _dummy_file(tmp_path)
result = cli(["integrations", "github", "add", "-a", "test", "--api-key", "key", "-f", str(f)], return_type=ReturnType.RAW)
assert result.exit_code != 0
@responses.activate
def test_integrations_github_add_personal_file_with_flags_error(tmp_path):
f = _dummy_file(tmp_path)
result = cli(["integrations", "github", "add-personal", "-a", "test", "--access-token", "token", "-f", str(f)], return_type=ReturnType.RAW)
assert result.exit_code != 0