Example #1
0
    def test_fire_master(self,
                         salt_crypt_sauth,
                         salt_transport_channel_factory):
        '''
        Test for Fire an event off up to the master server
        '''

        preload = {'id': 'id', 'tag': 'tag', 'data': 'data',
                   'tok': 'salt', 'cmd': '_minion_event'}

        with patch.dict(event.__opts__, {'transport': 'raet',
                                         'id': 'id',
                                         'local': False}):
            with patch.object(salt_transport_channel_factory, 'send',
                              return_value=None):
                self.assertTrue(event.fire_master('data', 'tag'))

        with patch.dict(event.__opts__, {'transport': 'A',
                                         'id': 'id',
                                         'master_uri': 'localhost',
                                         'local': False}):
            with patch.object(salt_crypt_sauth, 'gen_token',
                              return_value='tok'):
                with patch.object(salt_transport_channel_factory, 'send',
                                  return_value=None):
                    self.assertTrue(event.fire_master('data', 'tag', preload))

        with patch.dict(event.__opts__, {'transport': 'A', 'local': False}):
            with patch.object(salt.utils.event.MinionEvent, 'fire_event',
                              side_effect=Exception('foo')):
                self.assertFalse(event.fire_master('data', 'tag'))
Example #2
0
    def test_fire_master(self,
                         salt_crypt_sauth,
                         salt_transport_channel_factory):
        '''
        Test for Fire an event off up to the master server
        '''

        preload = {'id': 'id', 'tag': 'tag', 'data': 'data',
                   'tok': 'salt', 'cmd': '_minion_event'}

        with patch.dict(event.__opts__, {'transport': 'raet',
                                         'local': False}):
            with patch.object(salt_transport_channel_factory, 'send',
                              return_value=None):
                self.assertTrue(event.fire_master('data', 'tag'))

        with patch.dict(event.__opts__, {'transport': 'A',
                                         'master_uri': 'localhost',
                                         'local': False}):
            with patch.object(salt_crypt_sauth, 'gen_token',
                              return_value='tok'):
                with patch.object(salt_transport_channel_factory, 'send',
                                  return_value=None):
                    self.assertTrue(event.fire_master('data', 'tag', preload))

        with patch.dict(event.__opts__, {'transport': 'A', 'local': False}):
            with patch.object(salt.utils.event.MinionEvent, 'fire_event',
                              side_effect=Exception('foo')):
                self.assertFalse(event.fire_master('data', 'tag'))
Example #3
0
    def test_fire_master(self, salt_crypt_sauth, salt_transport_channel_factory):
        """
        Test for Fire an event off up to the master server
        """

        preload = {"id": "id", "tag": "tag", "data": "data", "tok": "salt", "cmd": "_minion_event"}

        with patch.dict(event.__opts__, {"transport": "raet", "id": "id"}):
            with patch.object(salt_transport_channel_factory, "send", return_value=None):
                self.assertTrue(event.fire_master("data", "tag"))

        with patch.dict(event.__opts__, {"transport": "A", "id": "id"}):
            with patch.object(salt_crypt_sauth, "gen_token", return_value="tok"):
                with patch.object(salt_transport_channel_factory, "send", return_value=None):
                    self.assertTrue(event.fire_master("data", "tag", preload))

        with patch.dict(event.__opts__, {"transport": "A"}):
            with patch.object(salt.utils.event.MinionEvent, "fire_event", side_effect=Exception("foo")):
                self.assertFalse(event.fire_master("data", "tag"))
Example #4
0
    def test_fire_master(self):
        """
        Test for Fire an event off up to the master server
        """
        with patch("salt.crypt.SAuth") as salt_crypt_sauth, patch(
                "salt.transport.client.ReqChannel.factory"
        ) as salt_transport_channel_factory:

            preload = {
                "id": "id",
                "tag": "tag",
                "data": "data",
                "tok": "salt",
                "cmd": "_minion_event",
            }

            with patch.dict(
                    event.__opts__,
                {
                    "transport": "A",
                    "master_uri": "localhost",
                    "local": False
                },
            ):
                with patch.object(salt_crypt_sauth,
                                  "gen_token",
                                  return_value="tok"):
                    with patch.object(salt_transport_channel_factory,
                                      "send",
                                      return_value=None):
                        self.assertTrue(
                            event.fire_master("data", "tag", preload))

            with patch.dict(event.__opts__, {
                    "transport": "A",
                    "local": False
            }):
                with patch.object(
                        salt.utils.event.MinionEvent,
                        "fire_event",
                        side_effect=Exception("foo"),
                ):
                    self.assertFalse(event.fire_master("data", "tag"))
Example #5
0
    def test_fire_master(self):
        """
        Test for Fire an event off up to the master server
        """
        with patch("salt.crypt.SAuth") as salt_crypt_sauth, patch(
                "salt.transport.client.ReqChannel.factory"
        ) as salt_transport_channel_factory:

            preload = {
                'id': 'id',
                'tag': 'tag',
                'data': 'data',
                'tok': 'salt',
                'cmd': '_minion_event'
            }

            with patch.dict(event.__opts__, {
                    'transport': 'A',
                    'master_uri': 'localhost',
                    'local': False
            }):
                with patch.object(salt_crypt_sauth,
                                  'gen_token',
                                  return_value='tok'):
                    with patch.object(salt_transport_channel_factory,
                                      'send',
                                      return_value=None):
                        self.assertTrue(
                            event.fire_master('data', 'tag', preload))

            with patch.dict(event.__opts__, {
                    "transport": "A",
                    "local": False
            }):
                with patch.object(
                        salt.utils.event.MinionEvent,
                        "fire_event",
                        side_effect=Exception("foo"),
                ):
                    self.assertFalse(event.fire_master("data", "tag"))