-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
53 additions
and
20 deletions.
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
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
init_config: | ||
|
||
instances: | ||
- http_endpoint: https://http-server-fips:443 | ||
- http_endpoint: https://http-server:443 | ||
|
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
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 |
---|---|---|
@@ -1,28 +1,45 @@ | ||
import subprocess | ||
import json | ||
import pytest | ||
import os | ||
|
||
FIPS_AGENT = 1 if "fips" in os.getenv("AGENT_TYPE") else 0 | ||
|
||
REGULAR_AGENT = { | ||
'http_status': 1, | ||
'http_status_fips_server': 1, | ||
'http_status_fips': 1, | ||
} | ||
FIPS_AGENT = { | ||
'http_status': 0, | ||
'http_status_fips_server': 1, | ||
'http_status_fips': 1, | ||
} | ||
|
||
|
||
def _parse_json(payload): | ||
""" | ||
Convert agent check json to dict of metric_name: value. | ||
""" | ||
parsed_json = {} | ||
for instance, suffix in zip(payload, ("", "_fips")): | ||
submitted_metrics = instance['aggregator']['metrics'] | ||
for metric_json in submitted_metrics: | ||
parsed_json[metric_json["metric"]+suffix] = int(metric_json["points"][-1][-1]) | ||
return parsed_json | ||
|
||
|
||
@pytest.skipif(FIPS_AGENT, reason="FIPS Agent enabled") | ||
def test_connections_regular_agent(): | ||
result = subprocess.run(["docker", "exec", "compose-agent-1", "agent", "check", "connections", "--json"], check=True, capture_output=True) | ||
check_json = json.loads(result.stdout) | ||
submitted_metrics = check_json[0]['aggregator']['metrics'] | ||
for metric_json in submitted_metrics: | ||
assert metric_json["points"][-1][-1] == 0 | ||
parsed_json = _parse_json(check_json) | ||
|
||
assert parsed_json == REGULAR_AGENT | ||
|
||
|
||
@pytest.skipif(not FIPS_AGENT, reason="FIPS Agent not enabled") | ||
def test_connections_fips_agent(): | ||
result = subprocess.run(["docker", "exec", "compose-agent-1", "agent", "check", "connections", "--json"], check=True, capture_output=True) | ||
check_json = json.loads(result.stdout) | ||
parsed_json = _parse_json(check_json) | ||
|
||
assert parsed_json == FIPS_AGENT |