def setUp(self):
     self.connection = MockConnection()
     self.gmp = Gmp(self.connection)
class GmpModifyTagTestCase(unittest.TestCase):
    def setUp(self):
        self.connection = MockConnection()
        self.gmp = Gmp(self.connection)

    def test_modify_tag(self):
        self.gmp.modify_tag(tag_id='t1')

        self.connection.send.has_been_called_with('<modify_tag tag_id="t1"/>')

    def test_modify_tag_missing_tag_id(self):
        with self.assertRaises(RequiredArgument):
            self.gmp.modify_tag(tag_id=None)

        with self.assertRaises(RequiredArgument):
            self.gmp.modify_tag(tag_id='')

    def test_modify_tag_with_comment(self):
        self.gmp.modify_tag(tag_id='t1', comment='foo')

        self.connection.send.has_been_called_with(
            '<modify_tag tag_id="t1"><comment>foo</comment></modify_tag>')

    def test_modify_tag_with_value(self):
        self.gmp.modify_tag(tag_id='t1', value='foo')

        self.connection.send.has_been_called_with(
            '<modify_tag tag_id="t1"><value>foo</value></modify_tag>')

    def test_modify_tag_with_name(self):
        self.gmp.modify_tag(tag_id='t1', name='foo')

        self.connection.send.has_been_called_with(
            '<modify_tag tag_id="t1"><name>foo</name></modify_tag>')

    def test_modify_tag_with_active(self):
        self.gmp.modify_tag(tag_id='t1', active=True)

        self.connection.send.has_been_called_with(
            '<modify_tag tag_id="t1"><active>1</active></modify_tag>')

        self.gmp.modify_tag(tag_id='t1', active=False)

        self.connection.send.has_been_called_with(
            '<modify_tag tag_id="t1"><active>0</active></modify_tag>')

    def test_modify_tag_with_resource_filter_and_type(self):
        self.gmp.modify_tag(tag_id='t1',
                            resource_filter='name=foo',
                            resource_type='task')

        self.connection.send.has_been_called_with(
            '<modify_tag tag_id="t1">'
            '<resources filter="name=foo">'
            '<type>task</type>'
            '</resources>'
            '</modify_tag>')

    def test_modify_tag_with_resource_action_filter_and_type(self):
        self.gmp.modify_tag(
            tag_id='t1',
            resource_action='set',
            resource_filter='name=foo',
            resource_type='task',
        )

        self.connection.send.has_been_called_with(
            '<modify_tag tag_id="t1">'
            '<resources action="set" filter="name=foo">'
            '<type>task</type>'
            '</resources>'
            '</modify_tag>')

    def test_modify_tag_with_resource_ids_and_type(self):
        self.gmp.modify_tag(tag_id='t1',
                            resource_ids=['r1'],
                            resource_type='task')

        self.connection.send.has_been_called_with('<modify_tag tag_id="t1">'
                                                  '<resources>'
                                                  '<resource id="r1"/>'
                                                  '<type>task</type>'
                                                  '</resources>'
                                                  '</modify_tag>')

    def test_modify_tag_with_resource_action_ids_and_type(self):
        self.gmp.modify_tag(
            tag_id='t1',
            resource_action="set",
            resource_ids=['r1'],
            resource_type='task',
        )

        self.connection.send.has_been_called_with('<modify_tag tag_id="t1">'
                                                  '<resources action="set">'
                                                  '<resource id="r1"/>'
                                                  '<type>task</type>'
                                                  '</resources>'
                                                  '</modify_tag>')

    def test_modify_tag_with_missing_resource_filter_or_ids_andtype(self):
        self.gmp.modify_tag(tag_id='t1', resource_action='add')

        self.connection.send.has_been_called_with('<modify_tag tag_id="t1">'
                                                  '<resources action="add"/>'
                                                  '</modify_tag>')

    def test_modify_tag_with_missing_resource_type(self):
        self.gmp.modify_tag(tag_id='t1', resource_ids=['r1'])

        self.connection.send.has_been_called_with('<modify_tag tag_id="t1">'
                                                  '<resources>'
                                                  '<resource id="r1"/>'
                                                  '</resources>'
                                                  '</modify_tag>')

        with self.assertRaises(RequiredArgument):
            self.gmp.modify_tag(tag_id='t1', resource_filter='name=foo')

    def test_modify_tag_with_missing_resource_filter_and_ids(self):
        self.gmp.modify_tag(tag_id='t1', resource_type='task')

        self.connection.send.has_been_called_with('<modify_tag tag_id="t1">'
                                                  '<resources>'
                                                  '<type>task</type>'
                                                  '</resources>'
                                                  '</modify_tag>')
Example #3
0
class GmpModifyTestCase(unittest.TestCase):
    def setUp(self):
        self.connection = MockConnection()
        self.gmp = Gmp(self.connection)

    def test_modify_credential(self):
        self.gmp.modify_credential(credential_id='c1', )

        self.connection.send.has_been_called_with(
            '<modify_credential credential_id="c1"/>')

    def test_modify_credential_missing_credential_id(self):
        with self.assertRaises(RequiredArgument):
            self.gmp.modify_credential(None)

        with self.assertRaises(RequiredArgument):
            self.gmp.modify_credential('')

        with self.assertRaises(RequiredArgument):
            self.gmp.modify_credential(credential_id='')

    def test_modify_credential_with_name(self):
        self.gmp.modify_credential(
            credential_id='c1',
            name='foo',
        )

        self.connection.send.has_been_called_with(
            '<modify_credential credential_id="c1">'
            '<name>foo</name>'
            '</modify_credential>')

    def test_modify_credential_with_comment(self):
        self.gmp.modify_credential(
            credential_id='c1',
            comment='foo',
        )

        self.connection.send.has_been_called_with(
            '<modify_credential credential_id="c1">'
            '<comment>foo</comment>'
            '</modify_credential>')

    def test_modify_credential_with_certificate(self):
        self.gmp.modify_credential(
            credential_id='c1',
            certificate='abcdef',
        )

        self.connection.send.has_been_called_with(
            '<modify_credential credential_id="c1">'
            '<certificate>abcdef</certificate>'
            '</modify_credential>')

    def test_modify_credential_with_private_key_and_key_phrase(self):
        self.gmp.modify_credential(credential_id='c1',
                                   private_key='123456',
                                   key_phrase='foo')

        self.connection.send.has_been_called_with(
            '<modify_credential credential_id="c1">'
            '<key>'
            '<phrase>foo</phrase>'
            '<private>123456</private>'
            '</key>'
            '</modify_credential>')

    def test_modify_credential_missing_private_key(self):
        with self.assertRaises(RequiredArgument):
            self.gmp.modify_credential(
                credential_id='c1',
                key_phrase='foo',
            )

    def test_modify_credential_missing_key_phrase(self):
        with self.assertRaises(RequiredArgument):
            self.gmp.modify_credential(
                credential_id='c1',
                private_key='123456',
            )

    def test_modify_credential_with_allow_insecure(self):
        self.gmp.modify_credential(
            credential_id='c1',
            allow_insecure=True,
        )

        self.connection.send.has_been_called_with(
            '<modify_credential credential_id="c1">'
            '<allow_insecure>1</allow_insecure>'
            '</modify_credential>')

        self.gmp.modify_credential(
            credential_id='c1',
            allow_insecure=False,
        )

        self.connection.send.has_been_called_with(
            '<modify_credential credential_id="c1">'
            '<allow_insecure>0</allow_insecure>'
            '</modify_credential>')

    def test_modify_credential_with_login(self):
        self.gmp.modify_credential(
            credential_id='c1',
            login='******',
        )

        self.connection.send.has_been_called_with(
            '<modify_credential credential_id="c1">'
            '<login>foo</login>'
            '</modify_credential>')

    def test_modify_credential_with_password(self):
        self.gmp.modify_credential(
            credential_id='c1',
            password='******',
        )

        self.connection.send.has_been_called_with(
            '<modify_credential credential_id="c1">'
            '<password>foo</password>'
            '</modify_credential>')

    def test_modify_credential_with_auth_algorithm(self):
        self.gmp.modify_credential(
            credential_id='c1',
            auth_algorithm='md5',
        )

        self.connection.send.has_been_called_with(
            '<modify_credential credential_id="c1">'
            '<auth_algorithm>md5</auth_algorithm>'
            '</modify_credential>')

        self.gmp.modify_credential(
            credential_id='c1',
            auth_algorithm='sha1',
        )

        self.connection.send.has_been_called_with(
            '<modify_credential credential_id="c1">'
            '<auth_algorithm>sha1</auth_algorithm>'
            '</modify_credential>')

    def test_modify_credential_invalid_auth_algorithm(self):
        with self.assertRaises(InvalidArgument):
            self.gmp.modify_credential(
                credential_id='c1',
                auth_algorithm='foo',
            )

    def test_modify_credential_with_community(self):
        self.gmp.modify_credential(
            credential_id='c1',
            community='foo',
        )

        self.connection.send.has_been_called_with(
            '<modify_credential credential_id="c1">'
            '<community>foo</community>'
            '</modify_credential>')

    def test_modify_credential_with_privacy_algorithm(self):
        self.gmp.modify_credential(
            credential_id='c1',
            privacy_algorithm='aes',
        )

        self.connection.send.has_been_called_with(
            '<modify_credential credential_id="c1">'
            '<privacy>'
            '<algorithm>aes</algorithm>'
            '</privacy>'
            '</modify_credential>')

        self.gmp.modify_credential(
            credential_id='c1',
            privacy_algorithm='des',
        )

        self.connection.send.has_been_called_with(
            '<modify_credential credential_id="c1">'
            '<privacy>'
            '<algorithm>des</algorithm>'
            '</privacy>'
            '</modify_credential>')

    def test_modify_credential_invalid_privacy_algorithm(self):
        with self.assertRaises(InvalidArgument):
            self.gmp.modify_credential(
                credential_id='c1',
                privacy_algorithm='',
            )

        with self.assertRaises(InvalidArgument):
            self.gmp.modify_credential(
                credential_id='c1',
                privacy_algorithm='foo',
            )

    def test_modify_credential_with_privacy_password(self):
        self.gmp.modify_credential(
            credential_id='c1',
            privacy_password='******',
        )

        self.connection.send.has_been_called_with(
            '<modify_credential credential_id="c1">'
            '<privacy>'
            '<password>foo</password>'
            '</privacy>'
            '</modify_credential>')

    def test_modify_credential_with_public_key(self):
        self.gmp.modify_credential(
            credential_id='c1',
            public_key='foo',
        )

        self.connection.send.has_been_called_with(
            '<modify_credential credential_id="c1">'
            '<key>'
            '<public>foo</public>'
            '</key>'
            '</modify_credential>')

    def test_modify_credential_with_credential_type(self):
        self.gmp.modify_credential(
            credential_id='c1',
            credential_type='up',
        )

        self.connection.send.has_been_called_with(
            '<modify_credential credential_id="c1">'
            '<type>up</type>'
            '</modify_credential>')

    def test_modify_credential_invalid_credential_type(self):
        with self.assertRaises(InvalidArgument):
            self.gmp.modify_credential(
                credential_id='c1',
                credential_type='foo',
            )
Example #4
0
class GmpCreateCredentialTestCase(unittest.TestCase):
    def setUp(self):
        self.connection = MockConnection()
        self.gmp = Gmp(self.connection)

    def test_create_up_credential_missing_name(self):
        with self.assertRaises(RequiredArgument):
            self.gmp.create_credential(name='',
                                       credential_type='up',
                                       login='******')

        with self.assertRaises(RequiredArgument):
            self.gmp.create_credential(name=None,
                                       credential_type='up',
                                       login='******')

    def test_create_up_credential(self):
        self.gmp.create_credential(
            name='foo',
            credential_type='up',
            comment='bar',
            login='******',
            password='******',
        )

        self.connection.send.has_been_called_with('<create_credential>'
                                                  '<name>foo</name>'
                                                  '<type>up</type>'
                                                  '<comment>bar</comment>'
                                                  '<login>Max</login>'
                                                  '<password>123</password>'
                                                  '</create_credential>')

    def test_create_up_credential_with_allow_insecure(self):
        self.gmp.create_credential(
            name='foo',
            credential_type='up',
            comment='bar',
            login='******',
            password='******',
            allow_insecure=True,
        )

        self.connection.send.has_been_called_with(
            '<create_credential>'
            '<name>foo</name>'
            '<type>up</type>'
            '<comment>bar</comment>'
            '<allow_insecure>1</allow_insecure>'
            '<login>Max</login>'
            '<password>123</password>'
            '</create_credential>')

        self.gmp.create_credential(
            name='foo',
            credential_type='up',
            comment='bar',
            login='******',
            password='******',
            allow_insecure=False,
        )

        self.connection.send.has_been_called_with(
            '<create_credential>'
            '<name>foo</name>'
            '<type>up</type>'
            '<comment>bar</comment>'
            '<allow_insecure>0</allow_insecure>'
            '<login>Max</login>'
            '<password>123</password>'
            '</create_credential>')

    def test_create_cc_credential_missing_certificate(self):
        with self.assertRaises(RequiredArgument):
            self.gmp.create_credential(name='foo', credential_type='cc')

    def test_create_cc_credential(self):
        self.gmp.create_credential(name='foo',
                                   credential_type='cc',
                                   certificate='abcdef')

        self.connection.send.has_been_called_with(
            '<create_credential>'
            '<name>foo</name>'
            '<type>cc</type>'
            '<certificate>abcdef</certificate>'
            '</create_credential>')

    def test_create_cc_credential_with_private_key(self):
        self.gmp.create_credential(name='foo',
                                   credential_type='cc',
                                   certificate='abcdef',
                                   private_key='123456')

        self.connection.send.has_been_called_with(
            '<create_credential>'
            '<name>foo</name>'
            '<type>cc</type>'
            '<certificate>abcdef</certificate>'
            '<key>'
            '<private>123456</private>'
            '</key>'
            '</create_credential>')

    def test_create_usk_credential_missing_private_key(self):
        with self.assertRaises(RequiredArgument):
            self.gmp.create_credential(name='foo',
                                       credential_type='usk',
                                       login='******')

    def test_create_usk_credential_missing_login(self):
        with self.assertRaises(RequiredArgument):
            self.gmp.create_credential(name='foo',
                                       credential_type='usk',
                                       private_key='123456')

    def test_create_usk_credential(self):
        self.gmp.create_credential(name='foo',
                                   credential_type='usk',
                                   private_key='123456',
                                   login='******')

        self.connection.send.has_been_called_with('<create_credential>'
                                                  '<name>foo</name>'
                                                  '<type>usk</type>'
                                                  '<login>foo</login>'
                                                  '<key>'
                                                  '<private>123456</private>'
                                                  '</key>'
                                                  '</create_credential>')

    def test_create_usk_credential_with_key_phrase(self):
        self.gmp.create_credential(name='foo',
                                   credential_type='usk',
                                   private_key='123456',
                                   login='******',
                                   key_phrase='abcdef')

        self.connection.send.has_been_called_with('<create_credential>'
                                                  '<name>foo</name>'
                                                  '<type>usk</type>'
                                                  '<login>foo</login>'
                                                  '<key>'
                                                  '<private>123456</private>'
                                                  '<phrase>abcdef</phrase>'
                                                  '</key>'
                                                  '</create_credential>')

    def test_create_snmp_credential_invalid_auth_algorithm(self):
        with self.assertRaises(InvalidArgument):
            self.gmp.create_credential(name='foo',
                                       credential_type='snmp',
                                       login='******')

        with self.assertRaises(InvalidArgument):
            self.gmp.create_credential(name='foo',
                                       credential_type='snmp',
                                       login='******',
                                       auth_algorithm='')

        with self.assertRaises(InvalidArgument):
            self.gmp.create_credential(name='foo',
                                       credential_type='snmp',
                                       login='******',
                                       auth_algorithm='bar')

    def test_create_snmp_credential_auth_algorithm_md5(self):
        self.gmp.create_credential(name='foo',
                                   credential_type='snmp',
                                   login='******',
                                   auth_algorithm='md5')

        self.connection.send.has_been_called_with(
            '<create_credential>'
            '<name>foo</name>'
            '<type>snmp</type>'
            '<login>foo</login>'
            '<auth_algorithm>md5</auth_algorithm>'
            '</create_credential>')

    def test_create_snmp_credential_auth_algorithm_sha1(self):
        self.gmp.create_credential(name='foo',
                                   credential_type='snmp',
                                   login='******',
                                   auth_algorithm='sha1')

        self.connection.send.has_been_called_with(
            '<create_credential>'
            '<name>foo</name>'
            '<type>snmp</type>'
            '<login>foo</login>'
            '<auth_algorithm>sha1</auth_algorithm>'
            '</create_credential>')

    def test_create_snmp_credential_with_community(self):
        self.gmp.create_credential(name='foo',
                                   credential_type='snmp',
                                   login='******',
                                   auth_algorithm='sha1',
                                   community='ipsum')

        self.connection.send.has_been_called_with(
            '<create_credential>'
            '<name>foo</name>'
            '<type>snmp</type>'
            '<login>foo</login>'
            '<auth_algorithm>sha1</auth_algorithm>'
            '<community>ipsum</community>'
            '</create_credential>')

    def test_create_snmp_credential_invalid_privacy_algorithm(self):
        with self.assertRaises(InvalidArgument):
            self.gmp.create_credential(name='foo',
                                       credential_type='snmp',
                                       login='******',
                                       auth_algorithm='sha1',
                                       privacy_algorithm='')

        with self.assertRaises(InvalidArgument):
            self.gmp.create_credential(name='foo',
                                       credential_type='snmp',
                                       login='******',
                                       auth_algorithm='sha1',
                                       privacy_algorithm='foo')

    def test_create_snmp_credential_with_privacy_algorithm_aes(self):
        self.gmp.create_credential(name='foo',
                                   credential_type='snmp',
                                   login='******',
                                   auth_algorithm='sha1',
                                   privacy_algorithm='aes')

        self.connection.send.has_been_called_with(
            '<create_credential>'
            '<name>foo</name>'
            '<type>snmp</type>'
            '<login>foo</login>'
            '<auth_algorithm>sha1</auth_algorithm>'
            '<privacy>'
            '<algorithm>aes</algorithm>'
            '</privacy>'
            '</create_credential>')

    def test_create_snmp_credential_with_privacy_algorithm_des(self):
        self.gmp.create_credential(name='foo',
                                   credential_type='snmp',
                                   login='******',
                                   auth_algorithm='sha1',
                                   privacy_algorithm='des')

        self.connection.send.has_been_called_with(
            '<create_credential>'
            '<name>foo</name>'
            '<type>snmp</type>'
            '<login>foo</login>'
            '<auth_algorithm>sha1</auth_algorithm>'
            '<privacy>'
            '<algorithm>des</algorithm>'
            '</privacy>'
            '</create_credential>')

    def test_create_snmp_credential_with_privacy_password(self):
        self.gmp.create_credential(name='foo',
                                   credential_type='snmp',
                                   login='******',
                                   auth_algorithm='sha1',
                                   privacy_password='******')

        self.connection.send.has_been_called_with(
            '<create_credential>'
            '<name>foo</name>'
            '<type>snmp</type>'
            '<login>foo</login>'
            '<auth_algorithm>sha1</auth_algorithm>'
            '<privacy>'
            '<password>123</password>'
            '</privacy>'
            '</create_credential>')

    def test_create_smime_credential(self):
        self.gmp.create_credential(name='foo',
                                   credential_type='smime',
                                   certificate='ipsum')

        self.connection.send.has_been_called_with(
            '<create_credential>'
            '<name>foo</name>'
            '<type>smime</type>'
            '<certificate>ipsum</certificate>'
            '</create_credential>')

    def test_create_smime_credential_missing_certificate(self):
        with self.assertRaises(RequiredArgument):
            self.gmp.create_credential(name='foo', credential_type='smime')

    def test_create_pgp_credential(self):
        self.gmp.create_credential(name='foo',
                                   credential_type='pgp',
                                   public_key='ipsum')

        self.connection.send.has_been_called_with('<create_credential>'
                                                  '<name>foo</name>'
                                                  '<type>pgp</type>'
                                                  '<key>'
                                                  '<public>ipsum</public>'
                                                  '</key>'
                                                  '</create_credential>')

    def test_create_pgp_credential_missing_public_key(self):
        with self.assertRaises(RequiredArgument):
            self.gmp.create_credential(name='foo', credential_type='pgp')

    def test_create_credential_invalid_credential_type(self):
        with self.assertRaises(InvalidArgument):
            self.gmp.create_credential(name='foo', credential_type=None)

        with self.assertRaises(InvalidArgument):
            self.gmp.create_credential(name='foo', credential_type='')

        with self.assertRaises(InvalidArgument):
            self.gmp.create_credential(name='foo', credential_type='bar')
class GmpCreateTagTestCase(unittest.TestCase):
    def setUp(self):
        self.connection = MockConnection()
        self.gmp = Gmp(self.connection)

    def test_create_tag_missing_name(self):
        with self.assertRaises(RequiredArgument):
            self.gmp.create_tag(
                name=None, resource_ids=['foo'], resource_type='task'
            )

        with self.assertRaises(RequiredArgument):
            self.gmp.create_tag(
                name='', resource_ids=['foo'], resource_type='task'
            )

    def test_create_tag_missing_resource_filter_and_ids(self):
        self.gmp.create_tag(
            name='foo',
            resource_filter=None,
            resource_ids=None,
            resource_type='task',
        )

        self.connection.send.has_been_called_with(
            '<create_tag>'
            '<name>foo</name>'
            '<resources>'
            '<type>task</type>'
            '</resources>'
            '</create_tag>'
        )

        self.gmp.create_tag(
            name='foo',
            resource_filter=None,
            resource_ids=[],
            resource_type='task',
        )

        self.connection.send.has_been_called_with(
            '<create_tag>'
            '<name>foo</name>'
            '<resources>'
            '<type>task</type>'
            '</resources>'
            '</create_tag>'
        )

        self.gmp.create_tag(name='foo', resource_type='task')

        self.connection.send.has_been_called_with(
            '<create_tag>'
            '<name>foo</name>'
            '<resources>'
            '<type>task</type>'
            '</resources>'
            '</create_tag>'
        )

    def test_create_tag_both_resource_filter_and_ids(self):
        with self.assertRaises(InvalidArgument):
            self.gmp.create_tag(
                name='foo',
                resource_filter='name=foo',
                resource_ids=['foo'],
                resource_type='task',
            )

    def test_create_tag_missing_resource_type(self):
        with self.assertRaises(RequiredArgument):
            self.gmp.create_tag(
                name='foo',
                resource_type=None,
                resource_filter=None,
                resource_ids=['foo'],
            )

        with self.assertRaises(RequiredArgument):
            self.gmp.create_tag(
                name='foo',
                resource_type=None,
                resource_filter="name=foo",
                resource_ids=None,
            )

        with self.assertRaises(RequiredArgument):
            self.gmp.create_tag(
                name='foo', resource_type='', resource_ids=['foo']
            )

    def test_create_tag_with_resource_filter(self):
        self.gmp.create_tag(
            name='foo', resource_filter='name=foo', resource_type='task'
        )

        self.connection.send.has_been_called_with(
            '<create_tag>'
            '<name>foo</name>'
            '<resources filter="name=foo">'
            '<type>task</type>'
            '</resources>'
            '</create_tag>'
        )

    def test_create_tag_with_resource_ids(self):
        self.gmp.create_tag(
            name='foo', resource_ids=['foo'], resource_type='task'
        )

        self.connection.send.has_been_called_with(
            '<create_tag>'
            '<name>foo</name>'
            '<resources>'
            '<resource id="foo"/>'
            '<type>task</type>'
            '</resources>'
            '</create_tag>'
        )

        self.gmp.create_tag(
            name='foo', resource_ids=['foo', 'bar'], resource_type='task'
        )

        self.connection.send.has_been_called_with(
            '<create_tag>'
            '<name>foo</name>'
            '<resources>'
            '<resource id="foo"/>'
            '<resource id="bar"/>'
            '<type>task</type>'
            '</resources>'
            '</create_tag>'
        )

    def test_create_tag_with_comment(self):
        self.gmp.create_tag(
            name='foo',
            resource_ids=['foo'],
            resource_type='task',
            comment='bar',
        )

        self.connection.send.has_been_called_with(
            '<create_tag>'
            '<name>foo</name>'
            '<resources>'
            '<resource id="foo"/>'
            '<type>task</type>'
            '</resources>'
            '<comment>bar</comment>'
            '</create_tag>'
        )

    def test_create_tag_with_value(self):
        self.gmp.create_tag(
            name='foo', resource_ids=['foo'], resource_type='task', value='bar'
        )

        self.connection.send.has_been_called_with(
            '<create_tag>'
            '<name>foo</name>'
            '<resources>'
            '<resource id="foo"/>'
            '<type>task</type>'
            '</resources>'
            '<value>bar</value>'
            '</create_tag>'
        )

    def test_create_tag_with_active(self):
        self.gmp.create_tag(
            name='foo', resource_ids=['foo'], resource_type='task', active=True
        )

        self.connection.send.has_been_called_with(
            '<create_tag>'
            '<name>foo</name>'
            '<resources>'
            '<resource id="foo"/>'
            '<type>task</type>'
            '</resources>'
            '<active>1</active>'
            '</create_tag>'
        )

        self.gmp.create_tag(
            name='foo', resource_ids=['foo'], resource_type='task', active=False
        )

        self.connection.send.has_been_called_with(
            '<create_tag>'
            '<name>foo</name>'
            '<resources>'
            '<resource id="foo"/>'
            '<type>task</type>'
            '</resources>'
            '<active>0</active>'
            '</create_tag>'
        )