|
1 | 1 | import base64 |
| 2 | +import warnings |
2 | 3 | import json |
3 | 4 |
|
4 | 5 | from conductor.client.configuration.configuration import Configuration |
@@ -34,6 +35,54 @@ def test_initialization_with_basic_auth_server_api_url(): |
34 | 35 | } |
35 | 36 |
|
36 | 37 |
|
| 38 | +def test_base_url_with_api_path(): |
| 39 | + with warnings.catch_warnings(record=True) as w: |
| 40 | + warnings.simplefilter("always") |
| 41 | + configuration = Configuration(base_url="https://domain.com/api") |
| 42 | + assert len(w) == 1 |
| 43 | + assert "base_url' been passed with '/api' path" in str(w[0].message) |
| 44 | + assert configuration.host == "https://domain.com/api" |
| 45 | + |
| 46 | + |
| 47 | +def test_base_url_with_api_path_and_version(): |
| 48 | + with warnings.catch_warnings(record=True) as w: |
| 49 | + warnings.simplefilter("always") |
| 50 | + configuration = Configuration(base_url="https://domain.com/api/v1") |
| 51 | + assert len(w) == 1 |
| 52 | + assert "base_url' been passed with '/api' path" in str(w[0].message) |
| 53 | + assert configuration.host == "https://domain.com/api/v1" |
| 54 | + |
| 55 | + |
| 56 | +def test_base_url_with_api_subdomain_no_warning(): |
| 57 | + with warnings.catch_warnings(record=True) as w: |
| 58 | + warnings.simplefilter("always") |
| 59 | + configuration = Configuration(base_url="https://api.domain.com") |
| 60 | + assert len(w) == 0 |
| 61 | + assert configuration.host == "https://api.domain.com/api" |
| 62 | + |
| 63 | + |
| 64 | +def test_valid_base_url_no_warning(): |
| 65 | + with warnings.catch_warnings(record=True) as w: |
| 66 | + warnings.simplefilter("always") |
| 67 | + configuration = Configuration(base_url="https://domain.com") |
| 68 | + assert len(w) == 0 |
| 69 | + assert configuration.host == "https://domain.com/api" |
| 70 | + |
| 71 | + |
| 72 | +def test_base_url_with_port_no_warning(): |
| 73 | + with warnings.catch_warnings(record=True) as w: |
| 74 | + warnings.simplefilter("always") |
| 75 | + configuration = Configuration(base_url="https://domain.com:8080") |
| 76 | + assert len(w) == 0 |
| 77 | + assert configuration.host == "https://domain.com:8080/api" |
| 78 | + |
| 79 | + |
| 80 | +def test_base_url_with_api_subdomain_and_port_no_warning(): |
| 81 | + with warnings.catch_warnings(record=True) as w: |
| 82 | + warnings.simplefilter("always") |
| 83 | + configuration = Configuration(base_url="https://api.domain.com:8080") |
| 84 | + assert len(w) == 0 |
| 85 | + assert configuration.host == "https://api.domain.com:8080/api" |
37 | 86 | def test_ssl_ca_cert_initialization(): |
38 | 87 | configuration = Configuration( |
39 | 88 | base_url="https://internal.conductor.dev", ssl_ca_cert="/path/to/ca-cert.pem" |
|
0 commit comments