예제 #1
0
 def test_disable_insecure_serializers(self):
     with patch('kombu.serialization.registry') as registry:
         registry._decoders = ['pickle', 'yaml', 'doomsday']
         disable_insecure_serializers(allowed=['doomsday'])
         registry.disable.assert_has_calls([call('pickle'), call('yaml')])
         registry.enable.assert_has_calls([call('doomsday')])
         disable_insecure_serializers(allowed=None)
         registry.disable.assert_has_calls([
             call('pickle'), call('yaml'), call('doomsday')
         ])
예제 #2
0
 def test_disable_insecure_serializers(self):
     with patch('kombu.serialization.registry') as registry:
         registry._decoders = ['pickle', 'yaml', 'doomsday']
         disable_insecure_serializers(allowed=['doomsday'])
         registry.disable.assert_has_calls([call('pickle'), call('yaml')])
         registry.enable.assert_has_calls([call('doomsday')])
         disable_insecure_serializers(allowed=None)
         registry.disable.assert_has_calls([
             call('pickle'), call('yaml'), call('doomsday')
         ])
예제 #3
0
    def test_disable_insecure_serializers(self):
        try:
            disabled = registry._disabled_content_types
            self.assertTrue(disabled)

            disable_insecure_serializers(["application/json", "application/x-python-serialize"])
            self.assertIn("application/x-yaml", disabled)
            self.assertNotIn("application/json", disabled)
            self.assertNotIn("application/x-python-serialize", disabled)
            disabled.clear()

            disable_insecure_serializers(allowed=None)
            self.assertIn("application/x-yaml", disabled)
            self.assertIn("application/json", disabled)
            self.assertIn("application/x-python-serialize", disabled)
        finally:
            disable_insecure_serializers(allowed=["json"])
예제 #4
0
    def test_disable_insecure_serializers(self):
        try:
            disabled = registry._disabled_content_types
            assert disabled

            disable_insecure_serializers(
                ['application/json', 'application/x-python-serialize'], )
            assert 'application/x-yaml' in disabled
            assert 'application/json' not in disabled
            assert 'application/x-python-serialize' not in disabled
            disabled.clear()

            disable_insecure_serializers(allowed=None)
            assert 'application/x-yaml' in disabled
            assert 'application/json' in disabled
            assert 'application/x-python-serialize' in disabled
        finally:
            disable_insecure_serializers(allowed=['json'])
예제 #5
0
    def test_disable_insecure_serializers(self):
        try:
            disabled = registry._disabled_content_types
            self.assertTrue(disabled)

            disable_insecure_serializers(
                ['application/json', 'application/x-python-serialize'], )
            self.assertIn('application/x-yaml', disabled)
            self.assertNotIn('application/json', disabled)
            self.assertNotIn('application/x-python-serialize', disabled)
            disabled.clear()

            disable_insecure_serializers(allowed=None)
            self.assertIn('application/x-yaml', disabled)
            self.assertIn('application/json', disabled)
            self.assertIn('application/x-python-serialize', disabled)
        finally:
            disable_insecure_serializers(allowed=['json'])
예제 #6
0
    def test_disable_insecure_serializers(self):
        try:
            disabled = registry._disabled_content_types
            assert disabled

            disable_insecure_serializers(
                ['application/json', 'application/x-python-serialize'],
            )
            assert 'application/x-yaml' in disabled
            assert 'application/json' not in disabled
            assert 'application/x-python-serialize' not in disabled
            disabled.clear()

            disable_insecure_serializers(allowed=None)
            assert 'application/x-yaml' in disabled
            assert 'application/json' in disabled
            assert 'application/x-python-serialize' in disabled
        finally:
            disable_insecure_serializers(allowed=['json'])
예제 #7
0
    def test_disable_insecure_serializers(self):
        try:
            disabled = registry._disabled_content_types
            self.assertTrue(disabled)

            disable_insecure_serializers(
                ['application/json', 'application/x-python-serialize'],
            )
            self.assertIn('application/x-yaml', disabled)
            self.assertNotIn('application/json', disabled)
            self.assertNotIn('application/x-python-serialize', disabled)
            disabled.clear()

            disable_insecure_serializers(allowed=None)
            self.assertIn('application/x-yaml', disabled)
            self.assertIn('application/json', disabled)
            self.assertIn('application/x-python-serialize', disabled)
        finally:
            disable_insecure_serializers(allowed=['json'])