-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(anta.tests): Added test case for SSL certificate status as Verif…
…yCertificateStatus (#472) * issue-470: Added testcase for SSL certificate status as VerifyCertificateStatus * issue-470: Updated the testcase with more optimized code * issue-470: Added the support for optional encryption type and size * issue-472: Updated unit tests * issue-470: fix the linting issues * issue-470: fix unit tests for tox * issue-470: fix black issue * issue-470: fix utils liniting * issue-470: fix all linting issues * issue-470: improve code and unit tests * issue-470: Added few more unit tests * issue-470: fix the indetation for tests.yaml * issue-470: added the support of verify multiple certificate * issue-470: updated code for rsa and ecdsa key size * issue-470: fixed the pipeline --------- Co-authored-by: arista <atd-help@arista.com>
- Loading branch information
1 parent
e5abd13
commit 723f69d
Showing
5 changed files
with
512 additions
and
2 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
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,34 @@ | ||
# Copyright (c) 2023-2024 Arista Networks, Inc. | ||
# Use of this source code is governed by the Apache License 2.0 | ||
# that can be found in the LICENSE file. | ||
""" | ||
Toolkit for ANTA. | ||
""" | ||
from __future__ import annotations | ||
|
||
from typing import Any | ||
|
||
|
||
def get_failed_logs(expected_output: dict[Any, Any], actual_output: dict[Any, Any]) -> str: | ||
""" | ||
Get the failed log for a test. | ||
Returns the failed log or an empty string if there is no difference between the expected and actual output. | ||
Parameters: | ||
expected_output (dict): Expected output of a test. | ||
actual_output (dict): Actual output of a test | ||
Returns: | ||
str: Failed log of a test. | ||
""" | ||
failed_logs = [] | ||
|
||
for element, expected_data in expected_output.items(): | ||
actual_data = actual_output.get(element) | ||
|
||
if actual_data is None: | ||
failed_logs.append(f"\nExpected `{expected_data}` as the {element}, but it was not found in the actual output.") | ||
elif actual_data != expected_data: | ||
failed_logs.append(f"\nExpected `{expected_data}` as the {element}, but found `{actual_data}` instead.") | ||
|
||
return "".join(failed_logs) |
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
Oops, something went wrong.