| @@ 24-128 (lines=105) @@ | ||
| 21 | from gvm.errors import RequiredArgument, InvalidArgumentType |
|
| 22 | ||
| 23 | ||
| 24 | class GmpModifyPolicySetNvtSelectionTestCase: |
|
| 25 | def test_modify_policy_set_nvt_selection(self): |
|
| 26 | self.gmp.modify_policy_set_nvt_selection( |
|
| 27 | policy_id='c1', family='foo', nvt_oids=['o1'] |
|
| 28 | ) |
|
| 29 | ||
| 30 | self.connection.send.has_been_called_with( |
|
| 31 | '<modify_config config_id="c1">' |
|
| 32 | '<nvt_selection>' |
|
| 33 | '<family>foo</family>' |
|
| 34 | '<nvt oid="o1"/>' |
|
| 35 | '</nvt_selection>' |
|
| 36 | '</modify_config>' |
|
| 37 | ) |
|
| 38 | ||
| 39 | self.gmp.modify_policy_set_nvt_selection( |
|
| 40 | policy_id='c1', family='foo', nvt_oids=['o1', 'o2'] |
|
| 41 | ) |
|
| 42 | ||
| 43 | self.connection.send.has_been_called_with( |
|
| 44 | '<modify_config config_id="c1">' |
|
| 45 | '<nvt_selection>' |
|
| 46 | '<family>foo</family>' |
|
| 47 | '<nvt oid="o1"/>' |
|
| 48 | '<nvt oid="o2"/>' |
|
| 49 | '</nvt_selection>' |
|
| 50 | '</modify_config>' |
|
| 51 | ) |
|
| 52 | ||
| 53 | self.gmp.modify_policy_set_nvt_selection('c1', 'foo', ['o1']) |
|
| 54 | ||
| 55 | self.connection.send.has_been_called_with( |
|
| 56 | '<modify_config config_id="c1">' |
|
| 57 | '<nvt_selection>' |
|
| 58 | '<family>foo</family>' |
|
| 59 | '<nvt oid="o1"/>' |
|
| 60 | '</nvt_selection>' |
|
| 61 | '</modify_config>' |
|
| 62 | ) |
|
| 63 | ||
| 64 | self.gmp.modify_policy_set_nvt_selection('c1', 'foo', ('o1', 'o2')) |
|
| 65 | ||
| 66 | self.connection.send.has_been_called_with( |
|
| 67 | '<modify_config config_id="c1">' |
|
| 68 | '<nvt_selection>' |
|
| 69 | '<family>foo</family>' |
|
| 70 | '<nvt oid="o1"/>' |
|
| 71 | '<nvt oid="o2"/>' |
|
| 72 | '</nvt_selection>' |
|
| 73 | '</modify_config>' |
|
| 74 | ) |
|
| 75 | ||
| 76 | self.gmp.modify_policy_set_nvt_selection( |
|
| 77 | policy_id='c1', family='foo', nvt_oids=[] |
|
| 78 | ) |
|
| 79 | ||
| 80 | self.connection.send.has_been_called_with( |
|
| 81 | '<modify_config config_id="c1">' |
|
| 82 | '<nvt_selection>' |
|
| 83 | '<family>foo</family>' |
|
| 84 | '</nvt_selection>' |
|
| 85 | '</modify_config>' |
|
| 86 | ) |
|
| 87 | ||
| 88 | def test_modify_policy_set_nvt_selection_missing_config_id(self): |
|
| 89 | with self.assertRaises(RequiredArgument): |
|
| 90 | self.gmp.modify_policy_set_nvt_selection( |
|
| 91 | policy_id=None, family='foo', nvt_oids=['o1'] |
|
| 92 | ) |
|
| 93 | ||
| 94 | with self.assertRaises(RequiredArgument): |
|
| 95 | self.gmp.modify_policy_set_nvt_selection( |
|
| 96 | policy_id='', family='foo', nvt_oids=['o1'] |
|
| 97 | ) |
|
| 98 | ||
| 99 | with self.assertRaises(RequiredArgument): |
|
| 100 | self.gmp.modify_policy_set_nvt_selection('', 'foo', ['o1']) |
|
| 101 | ||
| 102 | def test_modify_policy_set_nvt_selection_missing_family(self): |
|
| 103 | with self.assertRaises(RequiredArgument): |
|
| 104 | self.gmp.modify_policy_set_nvt_selection( |
|
| 105 | policy_id='c1', family=None, nvt_oids=['o1'] |
|
| 106 | ) |
|
| 107 | ||
| 108 | with self.assertRaises(RequiredArgument): |
|
| 109 | self.gmp.modify_policy_set_nvt_selection( |
|
| 110 | policy_id='c1', family='', nvt_oids=['o1'] |
|
| 111 | ) |
|
| 112 | ||
| 113 | with self.assertRaises(RequiredArgument): |
|
| 114 | self.gmp.modify_policy_set_nvt_selection('c1', '', ['o1']) |
|
| 115 | ||
| 116 | def test_modify_policy_set_nvt_selection_invalid_nvt_oids(self): |
|
| 117 | with self.assertRaises(InvalidArgumentType): |
|
| 118 | self.gmp.modify_policy_set_nvt_selection( |
|
| 119 | policy_id='c1', family='foo', nvt_oids=None |
|
| 120 | ) |
|
| 121 | ||
| 122 | with self.assertRaises(InvalidArgumentType): |
|
| 123 | self.gmp.modify_policy_set_nvt_selection( |
|
| 124 | policy_id='c1', family='foo', nvt_oids='' |
|
| 125 | ) |
|
| 126 | ||
| 127 | with self.assertRaises(InvalidArgumentType): |
|
| 128 | self.gmp.modify_policy_set_nvt_selection('c1', 'foo', '') |
|
| 129 | ||
| 130 | ||
| 131 | if __name__ == '__main__': |
|
| @@ 24-128 (lines=105) @@ | ||
| 21 | from gvm.errors import RequiredArgument, InvalidArgumentType |
|
| 22 | ||
| 23 | ||
| 24 | class GmpModifyPolicySetNvtSelectionTestCase: |
|
| 25 | def test_modify_policy_set_nvt_selection(self): |
|
| 26 | self.gmp.modify_policy_set_nvt_selection( |
|
| 27 | policy_id='c1', family='foo', nvt_oids=['o1'] |
|
| 28 | ) |
|
| 29 | ||
| 30 | self.connection.send.has_been_called_with( |
|
| 31 | '<modify_config config_id="c1">' |
|
| 32 | '<nvt_selection>' |
|
| 33 | '<family>foo</family>' |
|
| 34 | '<nvt oid="o1"/>' |
|
| 35 | '</nvt_selection>' |
|
| 36 | '</modify_config>' |
|
| 37 | ) |
|
| 38 | ||
| 39 | self.gmp.modify_policy_set_nvt_selection( |
|
| 40 | policy_id='c1', family='foo', nvt_oids=['o1', 'o2'] |
|
| 41 | ) |
|
| 42 | ||
| 43 | self.connection.send.has_been_called_with( |
|
| 44 | '<modify_config config_id="c1">' |
|
| 45 | '<nvt_selection>' |
|
| 46 | '<family>foo</family>' |
|
| 47 | '<nvt oid="o1"/>' |
|
| 48 | '<nvt oid="o2"/>' |
|
| 49 | '</nvt_selection>' |
|
| 50 | '</modify_config>' |
|
| 51 | ) |
|
| 52 | ||
| 53 | self.gmp.modify_policy_set_nvt_selection('c1', 'foo', ['o1']) |
|
| 54 | ||
| 55 | self.connection.send.has_been_called_with( |
|
| 56 | '<modify_config config_id="c1">' |
|
| 57 | '<nvt_selection>' |
|
| 58 | '<family>foo</family>' |
|
| 59 | '<nvt oid="o1"/>' |
|
| 60 | '</nvt_selection>' |
|
| 61 | '</modify_config>' |
|
| 62 | ) |
|
| 63 | ||
| 64 | self.gmp.modify_policy_set_nvt_selection('c1', 'foo', ('o1', 'o2')) |
|
| 65 | ||
| 66 | self.connection.send.has_been_called_with( |
|
| 67 | '<modify_config config_id="c1">' |
|
| 68 | '<nvt_selection>' |
|
| 69 | '<family>foo</family>' |
|
| 70 | '<nvt oid="o1"/>' |
|
| 71 | '<nvt oid="o2"/>' |
|
| 72 | '</nvt_selection>' |
|
| 73 | '</modify_config>' |
|
| 74 | ) |
|
| 75 | ||
| 76 | self.gmp.modify_policy_set_nvt_selection( |
|
| 77 | policy_id='c1', family='foo', nvt_oids=[] |
|
| 78 | ) |
|
| 79 | ||
| 80 | self.connection.send.has_been_called_with( |
|
| 81 | '<modify_config config_id="c1">' |
|
| 82 | '<nvt_selection>' |
|
| 83 | '<family>foo</family>' |
|
| 84 | '</nvt_selection>' |
|
| 85 | '</modify_config>' |
|
| 86 | ) |
|
| 87 | ||
| 88 | def test_modify_policy_set_nvt_selection_missing_config_id(self): |
|
| 89 | with self.assertRaises(RequiredArgument): |
|
| 90 | self.gmp.modify_policy_set_nvt_selection( |
|
| 91 | policy_id=None, family='foo', nvt_oids=['o1'] |
|
| 92 | ) |
|
| 93 | ||
| 94 | with self.assertRaises(RequiredArgument): |
|
| 95 | self.gmp.modify_policy_set_nvt_selection( |
|
| 96 | policy_id='', family='foo', nvt_oids=['o1'] |
|
| 97 | ) |
|
| 98 | ||
| 99 | with self.assertRaises(RequiredArgument): |
|
| 100 | self.gmp.modify_policy_set_nvt_selection('', 'foo', ['o1']) |
|
| 101 | ||
| 102 | def test_modify_policy_set_nvt_selection_missing_family(self): |
|
| 103 | with self.assertRaises(RequiredArgument): |
|
| 104 | self.gmp.modify_policy_set_nvt_selection( |
|
| 105 | policy_id='c1', family=None, nvt_oids=['o1'] |
|
| 106 | ) |
|
| 107 | ||
| 108 | with self.assertRaises(RequiredArgument): |
|
| 109 | self.gmp.modify_policy_set_nvt_selection( |
|
| 110 | policy_id='c1', family='', nvt_oids=['o1'] |
|
| 111 | ) |
|
| 112 | ||
| 113 | with self.assertRaises(RequiredArgument): |
|
| 114 | self.gmp.modify_policy_set_nvt_selection('c1', '', ['o1']) |
|
| 115 | ||
| 116 | def test_modify_policy_set_nvt_selection_invalid_nvt_oids(self): |
|
| 117 | with self.assertRaises(InvalidArgumentType): |
|
| 118 | self.gmp.modify_policy_set_nvt_selection( |
|
| 119 | policy_id='c1', family='foo', nvt_oids=None |
|
| 120 | ) |
|
| 121 | ||
| 122 | with self.assertRaises(InvalidArgumentType): |
|
| 123 | self.gmp.modify_policy_set_nvt_selection( |
|
| 124 | policy_id='c1', family='foo', nvt_oids='' |
|
| 125 | ) |
|
| 126 | ||
| 127 | with self.assertRaises(InvalidArgumentType): |
|
| 128 | self.gmp.modify_policy_set_nvt_selection('c1', 'foo', '') |
|
| 129 | ||
| 130 | ||
| 131 | if __name__ == '__main__': |
|