forked from opensearch-project/opensearch-migrations
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Mikayla Thompson <thomika@amazon.com>
- Loading branch information
1 parent
6f0c2ae
commit 4534f6c
Showing
3 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...pture/dockerSolution/src/main/docker/migrationConsole/console_link/tests/requirements.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pytest |
50 changes: 50 additions & 0 deletions
50
...apture/dockerSolution/src/main/docker/migrationConsole/console_link/tests/test_cluster.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import pytest | ||
from console_link.models.cluster import Cluster | ||
|
||
# Define a valid cluster configuration | ||
valid_cluster_config = { | ||
'endpoint': "https://opensearchtarget:9200", | ||
'allow_insecure': True, | ||
'authorization': { | ||
'type': "basic", | ||
'details': { | ||
'username': "admin", | ||
'password': "myStrongPassword123!" | ||
} | ||
} | ||
} | ||
|
||
|
||
def test_valid_cluster_config(): | ||
cluster = Cluster(valid_cluster_config) | ||
assert isinstance(cluster, Cluster) | ||
|
||
|
||
def test_invalid_auth_type_refused(): | ||
invalid_auth_type = { | ||
'endpoint': "https://opensearchtarget:9200", | ||
'authorization': { | ||
'type': "invalid_type", | ||
} | ||
} | ||
with pytest.raises(ValueError) as excinfo: | ||
Cluster(invalid_auth_type) | ||
assert "Invalid config file for cluster" in excinfo.value.args[0] | ||
assert excinfo.value.args[1]['authorization'] == [{'type': ['unallowed value invalid_type']}] | ||
|
||
|
||
def test_missing_endpoint_refused(): | ||
missing_endpoint = { | ||
'allow_insecure': True, | ||
'authorization': { | ||
'type': "basic", | ||
'details': { | ||
'username': "XXXXX", | ||
'password': "XXXXXXXXXXXXXXXXXXX!" | ||
} | ||
} | ||
} | ||
with pytest.raises(ValueError) as excinfo: | ||
Cluster(missing_endpoint) | ||
assert "Invalid config file for cluster" in excinfo.value.args[0] | ||
assert excinfo.value.args[1]['endpoint'] == ['required field'] |