-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix missing test cases in quipucords api tests
Adds test cases that were missing because of missing functionality at the original time of writing the tests. This includes: - Tests for become methods with credentials - Scans that scan multiple sources and source types - A scan job that has a source that is expected to fail as well as a source that should succeed - Test case for satellite version options This commit also updates the different QCS objects "equivalent" method to make sure we are not missing values that the server is setting by default. Closes #130
- Loading branch information
Showing
17 changed files
with
391 additions
and
38 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
47 changes: 47 additions & 0 deletions
47
camayoc/tests/qcs/api/v1/credentials/test_manager_creds.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,47 @@ | ||
# coding=utf-8 | ||
"""Tests for the ``Credential`` API endpoint. | ||
:caseautomation: automated | ||
:casecomponent: api | ||
:caseimportance: high | ||
:caselevel: integration | ||
:requirement: Sonar | ||
:testtype: functional | ||
:upstream: yes | ||
""" | ||
import requests | ||
|
||
import pytest | ||
|
||
from camayoc.constants import ( | ||
QCS_HOST_MANAGER_TYPES, | ||
QCS_BECOME_METHODS, | ||
) | ||
from camayoc.qcs_models import Credential | ||
from camayoc.utils import uuid4 | ||
|
||
|
||
@pytest.mark.parametrize('method', QCS_BECOME_METHODS) | ||
@pytest.mark.parametrize('cred_type', QCS_HOST_MANAGER_TYPES) | ||
def test_negative_create_with_become( | ||
cred_type, shared_client, cleanup, method): | ||
"""Attempt to pass 'become' options to host manager credentials. | ||
:id: d04e3e1b-c7f1-4cc2-a4a4-a3d3317f95ce | ||
:description: Attempt to pass 'become' options that are only valid for | ||
network credentials to create host manager credentials. | ||
:steps: Attempt to create a host manager credential sending valid data | ||
along with the extra invalid become options. | ||
:expectedresults: An error is thrown and no new credential is created. | ||
""" | ||
cred = Credential( | ||
cred_type=cred_type, | ||
client=shared_client, | ||
password=uuid4(), | ||
become_method=method, | ||
become_password=uuid4(), | ||
become_user=uuid4(), | ||
) | ||
with pytest.raises(requests.HTTPError): | ||
cred.create() | ||
cleanup.append(cred) |
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,48 @@ | ||
# coding=utf-8 | ||
"""Tests for ``Scan`` API endpoint for quipucords server. | ||
:caseautomation: automated | ||
:casecomponent: api | ||
:caseimportance: high | ||
:caselevel: integration | ||
:requirement: Sonar | ||
:testtype: functional | ||
:upstream: yes | ||
""" | ||
|
||
import pytest | ||
|
||
from camayoc.tests.qcs.api.v1.utils import ( | ||
prep_all_source_scan, | ||
wait_until_state, | ||
) | ||
|
||
|
||
@pytest.mark.parametrize('scan_type', ['connect', 'inspect']) | ||
def test_multi_source_create(shared_client, cleanup, scan_type): | ||
"""Run a scan on a collection of sources and confirm it completes. | ||
:id: 43624cc1-6c41-4c2d-9919-c3d0aae83165 | ||
:description: Create sources for each source specified in the | ||
config file and then create a scan that scans all the sources. | ||
Provided the resources are specified in the config file, this will | ||
test that scans including multiple sources of mixed types can be | ||
created and complete. | ||
:steps: | ||
1) Create all credentials specified in config file | ||
2) Create all sources specified in config file, using appropriate | ||
credentials | ||
3) Create a scan using all sources | ||
4) Assert that the scan completes and a fact id is generated | ||
:expectedresults: A scan is run and has facts associated with it | ||
Also, scan results should be available during the scan. | ||
""" | ||
scan = prep_all_source_scan(cleanup, shared_client, scan_type) | ||
scan.create() | ||
if scan_type == 'inspect': | ||
wait_until_state(scan, state='running') | ||
assert 'connection_results' in scan.results().json().keys() | ||
assert 'inspection_results' in scan.results().json().keys() | ||
wait_until_state(scan, state='completed', timeout=600) | ||
if scan_type == 'inspect': | ||
assert scan.read().json().get('fact_collection_id') > 0 |
Oops, something went wrong.