-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #496 from y0urself/import-policy
Add import_policy
- Loading branch information
Showing
6 changed files
with
91 additions
and
0 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
51 changes: 51 additions & 0 deletions
51
tests/protocols/gmpv208/entities/policies/test_import_policy.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,51 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright (C) 2018-2021 Greenbone Networks GmbH | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
from gvm.errors import RequiredArgument, InvalidArgument | ||
|
||
|
||
class GmpImportPolicyTestMixin: | ||
|
||
POLICY_XML_STRING = ( | ||
'<get_configs_response status="200" status_text="OK">' | ||
'<config id="c4aa21e4-23e6-4064-ae49-c0d425738a98">' | ||
'<name>Foobar</name>' | ||
'<comment>Foobar config</comment>' | ||
'<creation_time>2018-11-09T10:48:03Z</creation_time>' | ||
'<modification_time>2018-11-09T10:48:03Z</modification_time>' | ||
'</config>' | ||
'</get_configs_response>' | ||
) | ||
|
||
def test_import_policy(self): | ||
self.gmp.import_policy(self.POLICY_XML_STRING) | ||
|
||
self.connection.send.has_been_called_with( | ||
'<create_config>' f'{self.POLICY_XML_STRING}' '</create_config>' | ||
) | ||
|
||
def test_import_missing_policy_xml(self): | ||
with self.assertRaises(RequiredArgument): | ||
self.gmp.import_policy(None) | ||
|
||
with self.assertRaises(RequiredArgument): | ||
self.gmp.import_policy('') | ||
|
||
def test_import_invalid_xml(self): | ||
with self.assertRaises(InvalidArgument): | ||
self.gmp.import_policy('abcdef') |
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