-
Notifications
You must be signed in to change notification settings - Fork 606
/
Copy pathtest_deploy_model_ssl_on_auth_on.py
48 lines (38 loc) · 1.67 KB
/
test_deploy_model_ssl_on_auth_on.py
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
import integ_test_base
import base64
import requests
import subprocess
class TestDeployModelSSLOnAuthOn(integ_test_base.IntegTestBase):
def _get_transfer_protocol(self) -> str:
return "https"
def _get_certificate_file_name(self) -> str:
return "./tests/integration/resources/2019_04_24_to_3018_08_25.crt"
def _get_key_file_name(self) -> str:
return "./tests/integration/resources/2019_04_24_to_3018_08_25.key"
def _get_pwd_file(self) -> str:
return "./tests/integration/resources/pwdfile.txt"
def test_deploy_ssl_on_auth_on(self):
# Uncomment the following line to preserve
# test case output and other files (config, state, ect.)
# in system temp folder.
# self.set_delete_temp_folder(False)
self.deploy_models(self._get_username(), self._get_password())
headers = {
"Content-Type": "application/json",
"TabPy-Client": "Integration test for deploying models with auth",
"Authorization": "Basic "
+ base64.b64encode("user1:P@ssw0rd".encode("utf-8")).decode("utf-8"),
}
session = requests.Session()
# Do not verify servers' cert to be signed by trusted CA
session.verify = False
# Do not warn about insecure request
requests.packages.urllib3.disable_warnings()
models = ["PCA", "Sentiment%20Analysis", "ttest", "anova"]
for m in models:
m_response = session.get(
url=f"{self._get_transfer_protocol()}://"
f"localhost:9004/endpoints/{m}",
headers=headers,
)
self.assertEqual(200, m_response.status_code)