Skip to content

Va v4 #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test-int-registry:
python -m pytest test/integration/test_container_registry_v1.py

test-int-va:
python -m pytest test/integration/test_vulnerability_advisor_v3.py
python -m pytest test/integration/test_vulnerability_advisor_v4.py

lint:
./pylint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# (C) Copyright IBM Corp. 2021.
# (C) Copyright IBM Corp. 2023.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -14,16 +14,16 @@
# limitations under the License.

"""
Examples for VulnerabilityAdvisorV3
Examples for VulnerabilityAdvisorV4
"""

from ibm_cloud_sdk_core import ApiException, read_external_sources
import os
import pytest
from ibm_cloud_sdk_core import ApiException, read_external_sources
from ibm_container_registry.vulnerability_advisor_v3 import *
from ibm_container_registry.vulnerability_advisor_v4 import *

account = 'accountID'
accept_language = 'en_US'
account = 'accountID'

#
# This file provides an example of how to use the Vulnerability Advisor service.
Expand All @@ -38,20 +38,20 @@
# in a configuration file and then:
# export IBM_CREDENTIALS_FILE=<name of configuration file>
#
config_file = 'vulnerability_advisor_v3.env'
config_file = 'vulnerability_advisor_v4.env'

vulnerability_advisor_service = None

config = None


##############################################################################
# Start of Examples for Service: VulnerabilityAdvisorV3
# Start of Examples for Service: VulnerabilityAdvisorV4
##############################################################################
# region
class TestVulnerabilityAdvisorV3Examples():
class TestVulnerabilityAdvisorV4Examples:
"""
Example Test Class for VulnerabilityAdvisorV3
Example Test Class for VulnerabilityAdvisorV4
"""

@classmethod
Expand All @@ -62,16 +62,16 @@ def setup_class(cls):

# begin-common

vulnerability_advisor_service = VulnerabilityAdvisorV3.new_instance(
account=account
vulnerability_advisor_service = VulnerabilityAdvisorV4.new_instance(
account=account,
)

# end-common
assert vulnerability_advisor_service is not None

# Load the configuration
global config
config = read_external_sources(VulnerabilityAdvisorV3.DEFAULT_SERVICE_NAME)
config = read_external_sources(VulnerabilityAdvisorV4.DEFAULT_SERVICE_NAME)

print('Setup complete.')

Expand All @@ -85,9 +85,11 @@ def test_account_report_query_path_example(self):
account_report_query_path request example
"""
try:
print('\naccount_report_query_path() result:')
# begin-accountReportQueryPath

scan_report_list = vulnerability_advisor_service.account_report_query_path().get_result()
response = vulnerability_advisor_service.account_report_query_path()
scan_report_list = response.get_result()

print(json.dumps(scan_report_list, indent=2))

Expand All @@ -102,9 +104,11 @@ def test_account_status_query_path_example(self):
account_status_query_path request example
"""
try:
print('\naccount_status_query_path() result:')
# begin-accountStatusQueryPath

scanreport_image_summary_list = vulnerability_advisor_service.account_status_query_path().get_result()
response = vulnerability_advisor_service.account_status_query_path()
scanreport_image_summary_list = response.get_result()

print(json.dumps(scanreport_image_summary_list, indent=2))

Expand All @@ -119,11 +123,13 @@ def test_image_report_query_path_example(self):
image_report_query_path request example
"""
try:
print('\nimage_report_query_path() result:')
# begin-imageReportQueryPath

scan_report = vulnerability_advisor_service.image_report_query_path(
name='image name'
).get_result()
response = vulnerability_advisor_service.image_report_query_path(
name='image name',
)
scan_report = response.get_result()

print(json.dumps(scan_report, indent=2))

Expand All @@ -138,11 +144,13 @@ def test_image_status_query_path_example(self):
image_status_query_path request example
"""
try:
print('\nimage_status_query_path() result:')
# begin-imageStatusQueryPath

scanreport_summary = vulnerability_advisor_service.image_status_query_path(
name='image name'
).get_result()
response = vulnerability_advisor_service.image_status_query_path(
name='image name',
)
scanreport_summary = response.get_result()

print(json.dumps(scanreport_summary, indent=2))

Expand All @@ -157,9 +165,11 @@ def test_list_exemption_account_example(self):
list_exemption_account request example
"""
try:
print('\nlist_exemption_account() result:')
# begin-listExemptionAccount

list_exemption = vulnerability_advisor_service.list_exemption_account().get_result()
response = vulnerability_advisor_service.list_exemption_account()
list_exemption = response.get_result()

print(json.dumps(list_exemption, indent=2))

Expand All @@ -174,12 +184,14 @@ def test_get_exemption_account_example(self):
get_exemption_account request example
"""
try:
print('\nget_exemption_account() result:')
# begin-getExemptionAccount

exemption = vulnerability_advisor_service.get_exemption_account(
response = vulnerability_advisor_service.get_exemption_account(
issue_type='cve',
issue_id='CVE-2020-0001'
).get_result()
issue_id='CVE-2023-0001',
)
exemption = response.get_result()

print(json.dumps(exemption, indent=2))

Expand All @@ -194,12 +206,14 @@ def test_create_exemption_account_example(self):
create_exemption_account request example
"""
try:
print('\ncreate_exemption_account() result:')
# begin-createExemptionAccount

exemption = vulnerability_advisor_service.create_exemption_account(
response = vulnerability_advisor_service.create_exemption_account(
issue_type='cve',
issue_id='CVE-2020-0001'
).get_result()
issue_id='CVE-2023-0001',
)
exemption = response.get_result()

print(json.dumps(exemption, indent=2))

Expand All @@ -214,11 +228,13 @@ def test_list_exemption_resource_example(self):
list_exemption_resource request example
"""
try:
print('\nlist_exemption_resource() result:')
# begin-listExemptionResource

list_exemption = vulnerability_advisor_service.list_exemption_resource(
resource='image name'
).get_result()
response = vulnerability_advisor_service.list_exemption_resource(
resource='image name',
)
list_exemption = response.get_result()

print(json.dumps(list_exemption, indent=2))

Expand All @@ -233,13 +249,15 @@ def test_get_exemption_resource_example(self):
get_exemption_resource request example
"""
try:
print('\nget_exemption_resource() result:')
# begin-getExemptionResource

exemption = vulnerability_advisor_service.get_exemption_resource(
response = vulnerability_advisor_service.get_exemption_resource(
resource='image name',
issue_type='cve',
issue_id='CVE-2020-0001'
).get_result()
issue_id='CVE-2023-0001',
)
exemption = response.get_result()

print(json.dumps(exemption, indent=2))

Expand All @@ -254,13 +272,15 @@ def test_create_exemption_resource_example(self):
create_exemption_resource request example
"""
try:
print('\ncreate_exemption_resource() result:')
# begin-createExemptionResource

exemption = vulnerability_advisor_service.create_exemption_resource(
response = vulnerability_advisor_service.create_exemption_resource(
resource='image name',
issue_type='cve',
issue_id='CVE-2020-0001'
).get_result()
issue_id='CVE-2023-0001',
)
exemption = response.get_result()

print(json.dumps(exemption, indent=2))

Expand All @@ -275,9 +295,11 @@ def test_exempt_handler_example(self):
exempt_handler request example
"""
try:
print('\nexempt_handler() result:')
# begin-exemptHandler

list_exemption_type_info = vulnerability_advisor_service.exempt_handler().get_result()
response = vulnerability_advisor_service.exempt_handler()
list_exemption_type_info = response.get_result()

print(json.dumps(list_exemption_type_info, indent=2))

Expand All @@ -292,9 +314,11 @@ def test_list_account_exemptions_example(self):
list_account_exemptions request example
"""
try:
print('\nlist_account_exemptions() result:')
# begin-listAccountExemptions

list_exemption = vulnerability_advisor_service.list_account_exemptions().get_result()
response = vulnerability_advisor_service.list_account_exemptions()
list_exemption = response.get_result()

print(json.dumps(list_exemption, indent=2))

Expand All @@ -309,9 +333,11 @@ def test_exemptions_account_delete_handler_example(self):
exemptions_account_delete_handler request example
"""
try:
print('\nexemptions_account_delete_handler() result:')
# begin-exemptionsAccountDeleteHandler

exemption_deletion_info = vulnerability_advisor_service.exemptions_account_delete_handler().get_result()
response = vulnerability_advisor_service.exemptions_account_delete_handler()
exemption_deletion_info = response.get_result()

print(json.dumps(exemption_deletion_info, indent=2))

Expand All @@ -326,11 +352,13 @@ def test_list_image_exemptions_example(self):
list_image_exemptions request example
"""
try:
print('\nlist_image_exemptions() result:')
# begin-listImageExemptions

list_exemption = vulnerability_advisor_service.list_image_exemptions(
resource='image name'
).get_result()
response = vulnerability_advisor_service.list_image_exemptions(
resource='image name',
)
list_exemption = response.get_result()

print(json.dumps(list_exemption, indent=2))

Expand All @@ -345,11 +373,13 @@ def test_list_bulk_image_exemptions_example(self):
list_bulk_image_exemptions request example
"""
try:
print('\nlist_bulk_image_exemptions() result:')
# begin-listBulkImageExemptions

exemptions_map = vulnerability_advisor_service.list_bulk_image_exemptions(
body=['image name']
).get_result()
response = vulnerability_advisor_service.list_bulk_image_exemptions(
body=['us.icr.io/birds/woodpecker:green', 'us.icr.io/birds/grebe:crested'],
)
exemptions_map = response.get_result()

print(json.dumps(exemptions_map, indent=2))

Expand All @@ -369,12 +399,11 @@ def test_delete_exemption_resource_example(self):
response = vulnerability_advisor_service.delete_exemption_resource(
resource='image name',
issue_type='cve',
issue_id='CVE-2020-0001'
).get_result()

print(json.dumps(response, indent=2))
issue_id='CVE-2023-0001',
)

# end-deleteExemptionResource
print('\ndelete_exemption_resource() response status code: ', response.get_status_code())

except ApiException as e:
pytest.fail(str(e))
Expand All @@ -389,17 +418,17 @@ def test_delete_exemption_account_example(self):

response = vulnerability_advisor_service.delete_exemption_account(
issue_type='cve',
issue_id='CVE-2020-0001'
).get_result()

print(json.dumps(response, indent=2))
issue_id='CVE-2023-0001',
)

# end-deleteExemptionAccount
print('\ndelete_exemption_account() response status code: ', response.get_status_code())

except ApiException as e:
pytest.fail(str(e))


# endregion
##############################################################################
# End of Examples for Service: VulnerabilityAdvisorV3
# End of Examples for Service: VulnerabilityAdvisorV4
##############################################################################
Loading