stoobly-agent 1.10.1__py3-none-any.whl → 1.10.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- stoobly_agent/__init__.py +1 -1
- stoobly_agent/__main__.py +10 -0
- stoobly_agent/app/cli/ca_cert_cli.py +9 -5
- stoobly_agent/app/cli/helpers/replay_facade.py +2 -2
- stoobly_agent/app/cli/intercept_cli.py +5 -5
- stoobly_agent/app/cli/request_cli.py +2 -2
- stoobly_agent/app/cli/scaffold/app.py +14 -5
- stoobly_agent/app/cli/scaffold/app_command.py +0 -4
- stoobly_agent/app/cli/scaffold/app_config.py +49 -2
- stoobly_agent/app/cli/scaffold/app_create_command.py +145 -76
- stoobly_agent/app/cli/scaffold/constants.py +8 -1
- stoobly_agent/app/cli/scaffold/docker/constants.py +3 -1
- stoobly_agent/app/cli/scaffold/docker/service/build_decorator.py +2 -2
- stoobly_agent/app/cli/scaffold/docker/service/builder.py +15 -49
- stoobly_agent/app/cli/scaffold/docker/service/configure_gateway.py +3 -0
- stoobly_agent/app/cli/scaffold/docker/template_files.py +112 -0
- stoobly_agent/app/cli/scaffold/docker/workflow/build_decorator.py +1 -1
- stoobly_agent/app/cli/scaffold/docker/workflow/builder.py +31 -39
- stoobly_agent/app/cli/scaffold/docker/workflow/command_decorator.py +1 -1
- stoobly_agent/app/cli/scaffold/docker/workflow/detached_decorator.py +1 -1
- stoobly_agent/app/cli/scaffold/docker/workflow/dns_decorator.py +2 -3
- stoobly_agent/app/cli/scaffold/docker/workflow/local_decorator.py +1 -1
- stoobly_agent/app/cli/scaffold/docker/workflow/mock_decorator.py +1 -1
- stoobly_agent/app/cli/scaffold/docker/workflow/reverse_proxy_decorator.py +1 -1
- stoobly_agent/app/cli/scaffold/docker/workflow/run_command.py +423 -0
- stoobly_agent/app/cli/scaffold/local/__init__.py +0 -0
- stoobly_agent/app/cli/scaffold/local/service/__init__.py +0 -0
- stoobly_agent/app/cli/scaffold/local/service/builder.py +72 -0
- stoobly_agent/app/cli/scaffold/local/workflow/__init__.py +0 -0
- stoobly_agent/app/cli/scaffold/local/workflow/builder.py +35 -0
- stoobly_agent/app/cli/scaffold/local/workflow/run_command.py +339 -0
- stoobly_agent/app/cli/scaffold/service_command.py +9 -1
- stoobly_agent/app/cli/scaffold/service_config.py +8 -0
- stoobly_agent/app/cli/scaffold/service_create_command.py +18 -6
- stoobly_agent/app/cli/scaffold/service_docker_compose.py +1 -1
- stoobly_agent/app/cli/scaffold/templates/app/.Makefile +2 -2
- stoobly_agent/app/cli/scaffold/templates/app/build/.docker-compose.base.yml +2 -2
- stoobly_agent/app/cli/scaffold/templates/app/entrypoint/.docker-compose.base.yml +2 -2
- stoobly_agent/app/cli/scaffold/templates/app/entrypoint/mock/run +3 -0
- stoobly_agent/app/cli/scaffold/templates/app/entrypoint/record/run +3 -0
- stoobly_agent/app/cli/scaffold/templates/app/entrypoint/test/run +3 -0
- stoobly_agent/app/cli/scaffold/templates/build/services/build/mock/.configure +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/services/build/mock/.init +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/services/build/mock/.run +14 -0
- stoobly_agent/app/cli/scaffold/templates/build/services/build/record/.configure +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/services/build/record/.init +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/services/build/record/.run +14 -0
- stoobly_agent/app/cli/scaffold/templates/build/services/build/test/.configure +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/services/build/test/.init +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/services/build/test/.run +14 -0
- stoobly_agent/app/cli/scaffold/templates/build/services/entrypoint/mock/.configure +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/services/entrypoint/mock/.init +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/services/entrypoint/mock/.run +19 -0
- stoobly_agent/app/cli/scaffold/templates/build/services/entrypoint/record/.configure +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/services/entrypoint/record/.init +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/services/entrypoint/record/.run +19 -0
- stoobly_agent/app/cli/scaffold/templates/build/services/entrypoint/test/.configure +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/services/entrypoint/test/.init +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/services/entrypoint/test/.run +19 -0
- stoobly_agent/app/cli/scaffold/templates/build/workflows/exec/scaffold/.up +0 -1
- stoobly_agent/app/cli/scaffold/templates/build/workflows/mock/.configure +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/workflows/mock/.init +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/workflows/mock/.run +14 -0
- stoobly_agent/app/cli/scaffold/templates/build/workflows/record/.configure +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/workflows/record/.init +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/workflows/record/.run +14 -0
- stoobly_agent/app/cli/scaffold/templates/build/workflows/test/.configure +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/workflows/test/.init +5 -1
- stoobly_agent/app/cli/scaffold/templates/build/workflows/test/.run +14 -0
- stoobly_agent/app/cli/scaffold/templates/constants.py +35 -19
- stoobly_agent/app/cli/scaffold/templates/factory.py +34 -18
- stoobly_agent/app/cli/scaffold/templates/plugins/cypress/test/.run +21 -0
- stoobly_agent/app/cli/scaffold/templates/plugins/playwright/test/.run +21 -0
- stoobly_agent/app/cli/scaffold/templates/workflow/mock/run +3 -0
- stoobly_agent/app/cli/scaffold/templates/workflow/record/run +3 -0
- stoobly_agent/app/cli/scaffold/templates/workflow/test/run +3 -0
- stoobly_agent/app/cli/scaffold/workflow_command.py +18 -4
- stoobly_agent/app/cli/scaffold/workflow_copy_command.py +5 -4
- stoobly_agent/app/cli/scaffold/workflow_create_command.py +31 -29
- stoobly_agent/app/cli/scaffold/workflow_run_command.py +18 -151
- stoobly_agent/app/cli/scaffold_cli.py +115 -161
- stoobly_agent/app/cli/scenario_cli.py +2 -2
- stoobly_agent/app/cli/types/test.py +2 -2
- stoobly_agent/app/cli/types/workflow_run_command.py +52 -3
- stoobly_agent/app/proxy/handle_mock_service.py +1 -1
- stoobly_agent/app/proxy/intercept_settings.py +5 -25
- stoobly_agent/app/proxy/mock/eval_fixtures_service.py +177 -27
- stoobly_agent/app/proxy/mock/types/__init__.py +22 -1
- stoobly_agent/app/proxy/replay/body_parser_service.py +8 -5
- stoobly_agent/app/proxy/replay/multipart.py +15 -13
- stoobly_agent/app/proxy/replay/replay_request_service.py +2 -2
- stoobly_agent/app/proxy/run.py +3 -0
- stoobly_agent/app/proxy/test/context.py +0 -4
- stoobly_agent/app/proxy/test/context_abc.py +0 -5
- stoobly_agent/cli.py +61 -16
- stoobly_agent/config/data_dir.py +0 -8
- stoobly_agent/public/12-es2015.618ecfd5f735b801b50f.js +1 -0
- stoobly_agent/public/12-es5.618ecfd5f735b801b50f.js +1 -0
- stoobly_agent/public/index.html +1 -1
- stoobly_agent/public/runtime-es2015.77bcd31efed9e5d5d431.js +1 -0
- stoobly_agent/public/runtime-es5.77bcd31efed9e5d5d431.js +1 -0
- stoobly_agent/test/app/cli/intercept/intercept_configure_test.py +17 -6
- stoobly_agent/test/app/cli/scaffold/docker/cli_invoker.py +177 -0
- stoobly_agent/test/app/cli/scaffold/{cli_test.py → docker/cli_test.py} +1 -8
- stoobly_agent/test/app/cli/scaffold/{e2e_test.py → docker/e2e_test.py} +31 -16
- stoobly_agent/test/app/cli/scaffold/local/__init__.py +0 -0
- stoobly_agent/test/app/cli/scaffold/{cli_invoker.py → local/cli_invoker.py} +38 -32
- stoobly_agent/test/app/cli/scaffold/local/e2e_test.py +342 -0
- stoobly_agent/test/app/models/schemas/.stoobly/db/VERSION +1 -1
- stoobly_agent/test/app/proxy/mock/eval_fixtures_service_test.py +903 -2
- stoobly_agent/test/app/proxy/replay/body_parser_service_test.py +95 -3
- stoobly_agent/test/config/data_dir_test.py +2 -7
- stoobly_agent/test/test_helper.py +16 -5
- {stoobly_agent-1.10.1.dist-info → stoobly_agent-1.10.2.dist-info}/METADATA +4 -2
- {stoobly_agent-1.10.1.dist-info → stoobly_agent-1.10.2.dist-info}/RECORD +150 -122
- {stoobly_agent-1.10.1.dist-info → stoobly_agent-1.10.2.dist-info}/WHEEL +1 -1
- stoobly_agent/app/cli/helpers/shell.py +0 -26
- stoobly_agent/public/12-es2015.be58ed0ef449008b932e.js +0 -1
- stoobly_agent/public/12-es5.be58ed0ef449008b932e.js +0 -1
- stoobly_agent/public/runtime-es2015.f8c814b38b27708e91c1.js +0 -1
- stoobly_agent/public/runtime-es5.f8c814b38b27708e91c1.js +0 -1
- /stoobly_agent/app/cli/scaffold/templates/app/build/mock/{.docker-compose.mock.yml → .docker-compose.yml} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/build/mock/{bin/configure → configure} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/build/mock/{bin/init → init} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/build/record/{.docker-compose.record.yml → .docker-compose.yml} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/build/record/{bin/configure → configure} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/build/record/{bin/init → init} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/build/test/{.docker-compose.test.yml → .docker-compose.yml} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/build/test/{bin/configure → configure} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/build/test/{bin/init → init} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/entrypoint/mock/{.docker-compose.mock.yml → .docker-compose.yml} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/entrypoint/mock/{bin/configure → configure} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/entrypoint/mock/{bin/init → init} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/entrypoint/record/{.docker-compose.record.yml → .docker-compose.yml} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/entrypoint/record/{bin/configure → configure} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/entrypoint/record/{bin/init → init} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/entrypoint/test/{.docker-compose.test.yml → .docker-compose.yml} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/entrypoint/test/{bin/configure → configure} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/entrypoint/test/{bin/init → init} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/gateway/mock/{.docker-compose.mock.yml → .docker-compose.yml} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/gateway/record/{.docker-compose.record.yml → .docker-compose.yml} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/gateway/test/{.docker-compose.test.yml → .docker-compose.yml} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/stoobly-ui/exec/{.docker-compose.exec.yml → .docker-compose.yml} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/stoobly-ui/mock/{.docker-compose.mock.yml → .docker-compose.yml} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/app/stoobly-ui/record/{.docker-compose.record.yml → .docker-compose.yml} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/plugins/cypress/test/{.docker-compose.test.yml → .docker-compose.yml} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/plugins/playwright/test/{.docker-compose.test.yml → .docker-compose.yml} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/workflow/mock/{bin/configure → configure} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/workflow/mock/{bin/init → init} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/workflow/record/{bin/configure → configure} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/workflow/record/{bin/init → init} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/workflow/test/{bin/configure → configure} +0 -0
- /stoobly_agent/app/cli/scaffold/templates/workflow/test/{bin/init → init} +0 -0
- {stoobly_agent-1.10.1.dist-info → stoobly_agent-1.10.2.dist-info}/entry_points.txt +0 -0
- {stoobly_agent-1.10.1.dist-info → stoobly_agent-1.10.2.dist-info/licenses}/LICENSE +0 -0
@@ -0,0 +1,342 @@
|
|
1
|
+
import os
|
2
|
+
import pdb
|
3
|
+
import pytest
|
4
|
+
import requests
|
5
|
+
import time
|
6
|
+
|
7
|
+
from click.testing import CliRunner
|
8
|
+
import yaml
|
9
|
+
|
10
|
+
from stoobly_agent.app.cli.scaffold.app import App
|
11
|
+
from stoobly_agent.app.cli.scaffold.constants import (
|
12
|
+
SERVICES_NAMESPACE,
|
13
|
+
WORKFLOW_RECORD_TYPE,
|
14
|
+
WORKFLOW_TEST_TYPE,
|
15
|
+
WORKFLOW_MOCK_TYPE,
|
16
|
+
)
|
17
|
+
from stoobly_agent.app.cli.scaffold.workflow_command import WorkflowCommand
|
18
|
+
from stoobly_agent.app.settings import Settings
|
19
|
+
from stoobly_agent.config.constants import mode
|
20
|
+
from stoobly_agent.config.data_dir import DataDir
|
21
|
+
from stoobly_agent.lib.orm.request import Request
|
22
|
+
from stoobly_agent.test.app.cli.scaffold.local.cli_invoker import LocalScaffoldCliInvoker
|
23
|
+
from stoobly_agent.test.test_helper import reset
|
24
|
+
|
25
|
+
@pytest.mark.e2e
|
26
|
+
class TestLocalScaffoldE2e():
|
27
|
+
|
28
|
+
@pytest.fixture(scope='class', autouse=True)
|
29
|
+
def settings(self):
|
30
|
+
return reset()
|
31
|
+
|
32
|
+
@pytest.fixture(scope='module')
|
33
|
+
def runner(self):
|
34
|
+
yield CliRunner()
|
35
|
+
|
36
|
+
@pytest.fixture(scope='class')
|
37
|
+
def app_name(self):
|
38
|
+
yield "local-test-app"
|
39
|
+
|
40
|
+
@pytest.fixture(scope='class', autouse=True)
|
41
|
+
def app_dir_path(self):
|
42
|
+
data_dir: DataDir = DataDir.instance()
|
43
|
+
path = os.path.abspath(os.path.join(data_dir.tmp_dir_path, '..', '..'))
|
44
|
+
yield path
|
45
|
+
|
46
|
+
@pytest.fixture(scope='class')
|
47
|
+
def hostname(self):
|
48
|
+
yield "api.example.com"
|
49
|
+
|
50
|
+
@pytest.fixture(scope='class')
|
51
|
+
def https_service_hostname(self):
|
52
|
+
yield "secure.example.com"
|
53
|
+
|
54
|
+
@pytest.fixture(scope='class')
|
55
|
+
def external_service_name(self):
|
56
|
+
yield "external-api"
|
57
|
+
|
58
|
+
@pytest.fixture(scope='class')
|
59
|
+
def external_https_service_name(self):
|
60
|
+
yield "external-secure-api"
|
61
|
+
|
62
|
+
@pytest.fixture(scope='class')
|
63
|
+
def local_hostname(self):
|
64
|
+
yield "local-service.dev"
|
65
|
+
|
66
|
+
@pytest.fixture(scope='class')
|
67
|
+
def local_service_name(self):
|
68
|
+
yield "local-service"
|
69
|
+
|
70
|
+
@pytest.fixture(scope="class", autouse=True)
|
71
|
+
def proxy_url(self):
|
72
|
+
return "http://localhost:8081"
|
73
|
+
|
74
|
+
class TestRecordWorkflow():
|
75
|
+
@pytest.fixture(scope='class', autouse=True)
|
76
|
+
def target_workflow_name(self):
|
77
|
+
yield WORKFLOW_RECORD_TYPE
|
78
|
+
|
79
|
+
@pytest.fixture(scope="class", autouse=True)
|
80
|
+
def create_scaffold_setup(self, runner: CliRunner, app_dir_path: str, app_name: str, external_service_name: str, external_https_service_name: str, local_service_name: str, hostname: str, https_service_hostname: str, local_hostname: str):
|
81
|
+
# Create app with local run-on
|
82
|
+
LocalScaffoldCliInvoker.cli_app_create(runner, app_dir_path, app_name)
|
83
|
+
|
84
|
+
# Create external user defined services
|
85
|
+
LocalScaffoldCliInvoker.cli_service_create(runner, app_dir_path, hostname, external_service_name, False)
|
86
|
+
LocalScaffoldCliInvoker.cli_service_create(runner, app_dir_path, https_service_hostname, external_https_service_name, True)
|
87
|
+
|
88
|
+
# Create local user defined service
|
89
|
+
LocalScaffoldCliInvoker.cli_service_create_local(runner, app_dir_path, local_hostname, local_service_name)
|
90
|
+
|
91
|
+
@pytest.fixture(scope="class", autouse=True)
|
92
|
+
def workflow_up(self, runner: CliRunner, app_dir_path: str, target_workflow_name: str, settings: Settings):
|
93
|
+
"""Test workflow up command for local execution"""
|
94
|
+
LocalScaffoldCliInvoker.cli_workflow_up(runner, app_dir_path, target_workflow_name)
|
95
|
+
time.sleep(1)
|
96
|
+
settings.load()
|
97
|
+
|
98
|
+
@pytest.fixture(scope="class", autouse=True)
|
99
|
+
def test_workflow_down(self, runner: CliRunner, app_dir_path: str, proxy_url: str, target_workflow_name: str):
|
100
|
+
"""Test workflow down command for local execution"""
|
101
|
+
yield
|
102
|
+
|
103
|
+
LocalScaffoldCliInvoker.cli_workflow_down(runner, app_dir_path, target_workflow_name)
|
104
|
+
time.sleep(1)
|
105
|
+
|
106
|
+
try:
|
107
|
+
requests.get('https://docs.stoobly.com', proxies={'http': proxy_url, 'https': proxy_url}, verify=False)
|
108
|
+
assert False, "Expected ProxyError"
|
109
|
+
except requests.exceptions.ProxyError as e:
|
110
|
+
assert True
|
111
|
+
|
112
|
+
def test_request_proxied(self, proxy_url: str):
|
113
|
+
# Use http send request with proxy, do this in python, make the following not check ssl cert
|
114
|
+
res = requests.get('https://docs.stoobly.com', proxies={'http': proxy_url, 'https': proxy_url}, verify=False)
|
115
|
+
assert res.status_code == 200, "HTTP request with HTTP_PROXY and HTTPS_PROXY set to the local service should succeed"
|
116
|
+
|
117
|
+
def test_app_configuration(self, app_dir_path: str):
|
118
|
+
"""Test that the app is configured for local execution"""
|
119
|
+
app = App(app_dir_path, SERVICES_NAMESPACE)
|
120
|
+
assert app.valid, "App should be valid"
|
121
|
+
|
122
|
+
# Verify app is configured for local execution
|
123
|
+
from stoobly_agent.app.cli.scaffold.app_config import AppConfig
|
124
|
+
app_config = AppConfig(app.scaffold_namespace_path)
|
125
|
+
assert app_config.run_on_local, "App should be configured to run locally"
|
126
|
+
|
127
|
+
def test_services_exist(self, app_dir_path: str, external_service_name: str, local_service_name: str):
|
128
|
+
"""Test that services are created and configured properly"""
|
129
|
+
app = App(app_dir_path, SERVICES_NAMESPACE)
|
130
|
+
services = app.services
|
131
|
+
|
132
|
+
# Check that our services were created
|
133
|
+
assert external_service_name in services, f"External service {external_service_name} should exist"
|
134
|
+
assert local_service_name in services, f"Local service {local_service_name} should exist"
|
135
|
+
|
136
|
+
def test_workflow_logs(self, runner: CliRunner, app_dir_path: str, target_workflow_name: str):
|
137
|
+
"""Test workflow logs command for local execution"""
|
138
|
+
LocalScaffoldCliInvoker.cli_workflow_logs(runner, app_dir_path, target_workflow_name)
|
139
|
+
|
140
|
+
def test_intercept_mode_record(self, settings: Settings):
|
141
|
+
# Check stoobly-agent intercept show output starts with Mock
|
142
|
+
assert settings.proxy.intercept.mode == mode.RECORD
|
143
|
+
|
144
|
+
def test_intercept_mode_not_active(self, settings: Settings):
|
145
|
+
assert not settings.proxy.intercept.active
|
146
|
+
|
147
|
+
def test_records(self, settings: Settings, proxy_url: str):
|
148
|
+
_requests = Request.all()
|
149
|
+
assert len(_requests) == 0, "Expected 0 requests to be recorded"
|
150
|
+
settings.proxy.intercept.active = True
|
151
|
+
settings.commit()
|
152
|
+
time.sleep(1) # Wait for change to propagate
|
153
|
+
res = requests.get('https://docs.stoobly.com', proxies={'http': proxy_url, 'https': proxy_url}, verify=False)
|
154
|
+
assert res.status_code == 200, "HTTP request with HTTP_PROXY and HTTPS_PROXY set to the local service should succeed"
|
155
|
+
_requests = Request.all()
|
156
|
+
assert len(_requests) == 1, "Expected 1 request to be recorded"
|
157
|
+
|
158
|
+
|
159
|
+
class TestMockWorkflow():
|
160
|
+
@pytest.fixture(scope='class', autouse=True)
|
161
|
+
def target_workflow_name(self):
|
162
|
+
yield WORKFLOW_MOCK_TYPE
|
163
|
+
|
164
|
+
@pytest.fixture(scope="class", autouse=True)
|
165
|
+
def create_scaffold_setup(self, runner: CliRunner, app_dir_path: str, app_name: str, external_service_name: str, hostname: str, local_service_name: str, local_hostname: str):
|
166
|
+
# Create app with local run-on
|
167
|
+
LocalScaffoldCliInvoker.cli_app_create(runner, app_dir_path, app_name)
|
168
|
+
|
169
|
+
# Create external user defined service
|
170
|
+
LocalScaffoldCliInvoker.cli_service_create(runner, app_dir_path, hostname, external_service_name, False)
|
171
|
+
|
172
|
+
# Create local user defined service
|
173
|
+
LocalScaffoldCliInvoker.cli_service_create_local(runner, app_dir_path, local_hostname, local_service_name)
|
174
|
+
|
175
|
+
@pytest.fixture(scope="class", autouse=True)
|
176
|
+
def workflow_up(self, runner: CliRunner, app_dir_path: str, target_workflow_name: str, settings: Settings):
|
177
|
+
"""Test workflow up command for local execution"""
|
178
|
+
LocalScaffoldCliInvoker.cli_workflow_up(runner, app_dir_path, target_workflow_name)
|
179
|
+
time.sleep(1)
|
180
|
+
settings.load()
|
181
|
+
|
182
|
+
@pytest.fixture(scope="class", autouse=True)
|
183
|
+
def workflow_down(self, runner, app_dir_path, proxy_url: str, target_workflow_name):
|
184
|
+
yield
|
185
|
+
|
186
|
+
"""Test workflow down command for local execution"""
|
187
|
+
LocalScaffoldCliInvoker.cli_workflow_down(runner, app_dir_path, target_workflow_name)
|
188
|
+
time.sleep(1)
|
189
|
+
|
190
|
+
try:
|
191
|
+
requests.get('https://docs.stoobly.com', proxies={'http': proxy_url, 'https': proxy_url}, verify=False)
|
192
|
+
assert False, "Expected ProxyError"
|
193
|
+
except requests.exceptions.ProxyError as e:
|
194
|
+
assert True
|
195
|
+
|
196
|
+
def test_app_configuration(self, app_dir_path):
|
197
|
+
"""Test that the app is configured for local execution"""
|
198
|
+
app = App(app_dir_path, SERVICES_NAMESPACE)
|
199
|
+
assert app.valid, "App should be valid"
|
200
|
+
|
201
|
+
# Verify app is configured for local execution
|
202
|
+
from stoobly_agent.app.cli.scaffold.app_config import AppConfig
|
203
|
+
app_config = AppConfig(app.scaffold_namespace_path)
|
204
|
+
assert app_config.run_on_local, "App should be configured to run locally"
|
205
|
+
|
206
|
+
def test_services_exist(self, app_dir_path, external_service_name, local_service_name):
|
207
|
+
"""Test that services are created and configured properly"""
|
208
|
+
app = App(app_dir_path, SERVICES_NAMESPACE)
|
209
|
+
services = app.services
|
210
|
+
|
211
|
+
# Check that our services were created
|
212
|
+
assert external_service_name in services, f"External service {external_service_name} should exist"
|
213
|
+
assert local_service_name in services, f"Local service {local_service_name} should exist"
|
214
|
+
|
215
|
+
def test_workflow_up(self, proxy_url: str):
|
216
|
+
"""Test workflow up command for local execution"""
|
217
|
+
# Use http send request with proxy, do this in python, make the following not check ssl cert
|
218
|
+
res = requests.get('https://docs.stoobly.com', proxies={'http': proxy_url, 'https': proxy_url}, verify=False)
|
219
|
+
assert res.status_code == 499, "HTTP request with HTTP_PROXY and HTTPS_PROXY set to the local service should succeed"
|
220
|
+
|
221
|
+
def test_public_directory(self, app_dir_path: str, local_service_name: str, proxy_url: str, target_workflow_name: str):
|
222
|
+
"""Test public directory is created"""
|
223
|
+
app = App(app_dir_path, SERVICES_NAMESPACE)
|
224
|
+
workflow_command = WorkflowCommand(app, service_name=local_service_name, workflow_name=target_workflow_name)
|
225
|
+
assert os.path.exists(workflow_command.public_dir_path), "Public directory should be created"
|
226
|
+
# Create an index.html file in the public directory
|
227
|
+
with open(os.path.join(workflow_command.public_dir_path, 'index.html'), 'w') as f:
|
228
|
+
f.write('Hello World!')
|
229
|
+
res = requests.get(
|
230
|
+
workflow_command.service_config.url,
|
231
|
+
headers={'Accept': 'text/html'},
|
232
|
+
proxies={'http': proxy_url, 'https': proxy_url}, verify=False
|
233
|
+
)
|
234
|
+
assert res.status_code == 200
|
235
|
+
assert res.text == 'Hello World!'
|
236
|
+
|
237
|
+
def test_response_fixtures(self, app_dir_path: str, local_service_name: str, proxy_url: str, target_workflow_name: str):
|
238
|
+
"""Test response fixtures are created"""
|
239
|
+
app = App(app_dir_path, SERVICES_NAMESPACE)
|
240
|
+
workflow_command = WorkflowCommand(app, service_name=local_service_name, workflow_name=target_workflow_name)
|
241
|
+
assert os.path.exists(workflow_command.response_fixtures_path), "Response fixtures should be created"
|
242
|
+
|
243
|
+
contents = yaml.dump({'GET': {'/fixtures': {'path': os.path.basename(workflow_command.response_fixtures_path)}}})
|
244
|
+
# Create a fixtures.yml file in the response fixtures directory
|
245
|
+
with open(os.path.join(workflow_command.response_fixtures_path), 'w') as f:
|
246
|
+
f.write(contents)
|
247
|
+
|
248
|
+
res = requests.get(
|
249
|
+
workflow_command.service_config.url + '/fixtures',
|
250
|
+
proxies={'http': proxy_url, 'https': proxy_url}, verify=False
|
251
|
+
)
|
252
|
+
assert res.status_code == 200
|
253
|
+
assert res.text == contents
|
254
|
+
|
255
|
+
def test_workflow_logs(self, runner, app_dir_path, target_workflow_name):
|
256
|
+
"""Test workflow logs command for local execution"""
|
257
|
+
LocalScaffoldCliInvoker.cli_workflow_logs(runner, app_dir_path, target_workflow_name)
|
258
|
+
|
259
|
+
def test_intercept_mode_mock(self, settings: Settings):
|
260
|
+
# Check starts with Mock
|
261
|
+
assert settings.proxy.intercept.mode == mode.MOCK
|
262
|
+
|
263
|
+
def test_intercept_mode_active(self, settings: Settings):
|
264
|
+
assert settings.proxy.intercept.active
|
265
|
+
|
266
|
+
class TestTestWorkflow():
|
267
|
+
@pytest.fixture(scope='class', autouse=True)
|
268
|
+
def target_workflow_name(self):
|
269
|
+
yield WORKFLOW_TEST_TYPE
|
270
|
+
|
271
|
+
@pytest.fixture(scope='class')
|
272
|
+
def assets_service_name(self):
|
273
|
+
yield "assets"
|
274
|
+
|
275
|
+
@pytest.fixture(scope='class')
|
276
|
+
def assets_hostname(self):
|
277
|
+
yield "assets.local"
|
278
|
+
|
279
|
+
@pytest.fixture(scope="class", autouse=True)
|
280
|
+
def create_scaffold_setup(self, runner: CliRunner, app_name: str, app_dir_path: str, external_service_name: str, hostname: str, local_service_name: str, local_hostname: str):
|
281
|
+
# Create app with local run-on
|
282
|
+
LocalScaffoldCliInvoker.cli_app_create(runner, app_dir_path, app_name)
|
283
|
+
|
284
|
+
# Create external user defined service
|
285
|
+
LocalScaffoldCliInvoker.cli_service_create(runner, app_dir_path, hostname, external_service_name, False)
|
286
|
+
|
287
|
+
# Create local user defined service
|
288
|
+
LocalScaffoldCliInvoker.cli_service_create_local(runner, app_dir_path, local_hostname, local_service_name)
|
289
|
+
|
290
|
+
@pytest.fixture(scope="class", autouse=True)
|
291
|
+
def workflow_up(self, runner: CliRunner, app_dir_path: str, target_workflow_name: str, settings: Settings):
|
292
|
+
"""Test workflow up command for local execution"""
|
293
|
+
|
294
|
+
LocalScaffoldCliInvoker.cli_workflow_up(runner, app_dir_path, target_workflow_name)
|
295
|
+
time.sleep(1)
|
296
|
+
settings.load()
|
297
|
+
|
298
|
+
@pytest.fixture(scope="class", autouse=True)
|
299
|
+
def workflow_down(self, runner: CliRunner, app_dir_path: str, proxy_url: str, target_workflow_name: str):
|
300
|
+
yield
|
301
|
+
|
302
|
+
"""Test workflow down command for local execution"""
|
303
|
+
LocalScaffoldCliInvoker.cli_workflow_down(runner, app_dir_path, target_workflow_name)
|
304
|
+
time.sleep(1)
|
305
|
+
|
306
|
+
try:
|
307
|
+
requests.get('https://docs.stoobly.com', proxies={'http': proxy_url, 'https': proxy_url}, verify=False)
|
308
|
+
assert False, "Expected ProxyError"
|
309
|
+
except requests.exceptions.ProxyError as e:
|
310
|
+
assert True
|
311
|
+
|
312
|
+
def test_app_configuration(self, app_dir_path: str):
|
313
|
+
"""Test that the app is configured for local execution"""
|
314
|
+
app = App(app_dir_path, SERVICES_NAMESPACE)
|
315
|
+
assert app.valid, "App should be valid"
|
316
|
+
|
317
|
+
# Verify app is configured for local execution
|
318
|
+
from stoobly_agent.app.cli.scaffold.app_config import AppConfig
|
319
|
+
app_config = AppConfig(app.scaffold_namespace_path)
|
320
|
+
assert app_config.run_on_local, "App should be configured to run locally"
|
321
|
+
|
322
|
+
def test_services_exist(self, app_dir_path: str, external_service_name: str, local_service_name: str):
|
323
|
+
"""Test that services are created and configured properly"""
|
324
|
+
app = App(app_dir_path, SERVICES_NAMESPACE)
|
325
|
+
services = app.services
|
326
|
+
|
327
|
+
# Check that our services were created
|
328
|
+
assert external_service_name in services, f"External service {external_service_name} should exist"
|
329
|
+
assert local_service_name in services, f"Local service {local_service_name} should exist"
|
330
|
+
|
331
|
+
def test_workflow_up(self, proxy_url: str):
|
332
|
+
"""Test workflow up command for local execution"""
|
333
|
+
# Use http send request with proxy, do this in python, make the following not check ssl cert
|
334
|
+
res = requests.get('https://docs.stoobly.com', proxies={'http': proxy_url, 'https': proxy_url}, verify=False)
|
335
|
+
assert res.status_code == 499, "HTTP request with HTTP_PROXY and HTTPS_PROXY set to the local service should succeed"
|
336
|
+
|
337
|
+
def test_intercept_mode_mock(self, settings: Settings):
|
338
|
+
# Check starts with Mock
|
339
|
+
assert settings.proxy.intercept.mode == mode.MOCK
|
340
|
+
|
341
|
+
def test_intercept_mode_active(self, settings: Settings):
|
342
|
+
assert settings.proxy.intercept.active
|
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.10.1
|