|
1
|
|
|
from . import integ_test_base |
|
2
|
|
|
import base64 |
|
3
|
|
|
import requests |
|
4
|
|
|
|
|
5
|
|
|
|
|
6
|
|
|
class TestDeployModelSSLOnAuthOn(integ_test_base.IntegTestBase): |
|
7
|
|
|
def _get_transfer_protocol(self) -> str: |
|
8
|
|
|
return "https" |
|
9
|
|
|
|
|
10
|
|
|
def _get_certificate_file_name(self) -> str: |
|
11
|
|
|
return "./tests/integration/resources/2019_04_24_to_3018_08_25.crt" |
|
12
|
|
|
|
|
13
|
|
|
def _get_key_file_name(self) -> str: |
|
14
|
|
|
return "./tests/integration/resources/2019_04_24_to_3018_08_25.key" |
|
15
|
|
|
|
|
16
|
|
|
def _get_pwd_file(self) -> str: |
|
17
|
|
|
return "./tests/integration/resources/pwdfile.txt" |
|
18
|
|
|
|
|
19
|
|
View Code Duplication |
def test_deploy_ssl_on_auth_on(self): |
|
|
|
|
|
|
20
|
|
|
# Uncomment the following line to preserve |
|
21
|
|
|
# test case output and other files (config, state, ect.) |
|
22
|
|
|
# in system temp folder. |
|
23
|
|
|
# self.set_delete_temp_folder(False) |
|
24
|
|
|
|
|
25
|
|
|
self.deploy_models(self._get_username(), self._get_password()) |
|
26
|
|
|
|
|
27
|
|
|
headers = { |
|
28
|
|
|
"Content-Type": "application/json", |
|
29
|
|
|
"TabPy-Client": "Integration test for deploying models with auth", |
|
30
|
|
|
"Authorization": "Basic " |
|
31
|
|
|
+ base64.b64encode("user1:P@ssw0rd".encode("utf-8")).decode("utf-8"), |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
session = requests.Session() |
|
35
|
|
|
# Do not verify servers' cert to be signed by trusted CA |
|
36
|
|
|
session.verify = False |
|
37
|
|
|
# Do not warn about insecure request |
|
38
|
|
|
requests.packages.urllib3.disable_warnings() |
|
39
|
|
|
|
|
40
|
|
|
models = ["PCA", "Sentiment%20Analysis", "ttest", "anova"] |
|
41
|
|
|
for m in models: |
|
42
|
|
|
m_response = session.get( |
|
43
|
|
|
url=f"{self._get_transfer_protocol()}://" |
|
44
|
|
|
f"localhost:9004/endpoints/{m}", |
|
45
|
|
|
headers=headers, |
|
46
|
|
|
) |
|
47
|
|
|
self.assertEqual(200, m_response.status_code) |
|
48
|
|
|
|
|
49
|
|
View Code Duplication |
def test_override_model_ssl_on_auth_on(self): |
|
|
|
|
|
|
50
|
|
|
# Uncomment the following line to preserve |
|
51
|
|
|
# test case output and other files (config, state, ect.) |
|
52
|
|
|
# in system temp folder. |
|
53
|
|
|
# self.set_delete_temp_folder(False) |
|
54
|
|
|
|
|
55
|
|
|
self.deploy_models(self._get_username(), self._get_password()) |
|
56
|
|
|
|
|
57
|
|
|
# Override models |
|
58
|
|
|
self.deploy_models(self._get_username(), self._get_password()) |
|
59
|
|
|
|
|
60
|
|
|
headers = { |
|
61
|
|
|
"Content-Type": "application/json", |
|
62
|
|
|
"TabPy-Client": "Integration test for deploying models with auth", |
|
63
|
|
|
"Authorization": "Basic " |
|
64
|
|
|
+ base64.b64encode("user1:P@ssw0rd".encode("utf-8")).decode("utf-8"), |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
session = requests.Session() |
|
68
|
|
|
# Do not verify servers' cert to be signed by trusted CA |
|
69
|
|
|
session.verify = False |
|
70
|
|
|
# Do not warn about insecure request |
|
71
|
|
|
requests.packages.urllib3.disable_warnings() |
|
72
|
|
|
|
|
73
|
|
|
models = ["PCA", "Sentiment%20Analysis", "ttest", "anova"] |
|
74
|
|
|
for m in models: |
|
75
|
|
|
m_response = session.get( |
|
76
|
|
|
url=f"{self._get_transfer_protocol()}://" |
|
77
|
|
|
f"localhost:9004/endpoints/{m}", |
|
78
|
|
|
headers=headers, |
|
79
|
|
|
) |
|
80
|
|
|
self.assertEqual(200, m_response.status_code) |
|
81
|
|
|
|