Example #1
0
    def test_execute_model_request_with_valid_session(self):
        """
        """
        GASDKLibrary().register_sdk('default', tstdk)
        core_controller = GACoreController(
            garuda_uuid='test-garuda',
            redis_info={
                'host': '127.0.0.1',
                'port': 6379,
                'db': 6
            },
            additional_controller_classes=[AdditionalController],
            authentication_plugins=[FakeAuthPlugin()])

        request = GARequest(action=GARequest.ACTION_CREATE)
        request.resources = [GAResource(name='enterprise', value=None)]
        request.token = 'toto'

        with patch.object(core_controller.sessions_controller,
                          'get_session',
                          return_value=GASession(garuda_uuid='test-garuda',
                                                 root_object=tstdk.GARoot())):
            result = core_controller.execute_model_request(request)
            self.assertEquals(result.__class__,
                              GAResponseFailure)  # nothing exists that's fine
Example #2
0
    def test_execute_model_request_with_invalid_session(self):
        """
        """
        GASDKLibrary().register_sdk('default', tstdk)
        core_controller = GACoreController(
            garuda_uuid='test-garuda',
            redis_info={
                'host': '127.0.0.1',
                'port': 6379,
                'db': 6
            },
            additional_controller_classes=[AdditionalController])

        request = GARequest(action=GARequest.ACTION_CREATE)
        request.resources = [GAResource(name='enterprise', value=None)]

        with patch.object(core_controller.sessions_controller,
                          'get_session',
                          return_value=None):
            with patch.object(core_controller.sessions_controller,
                              'get_session',
                              return_value=None):
                with patch.object(FakeAuthPlugin,
                                  'authenticate',
                                  return_value=None):
                    result = core_controller.execute_model_request(request)
                    self.assertEquals(result.__class__, GAResponseFailure)
                    self.assertEquals(result.content[0].type,
                                      GAError.TYPE_UNAUTHORIZED)
Example #3
0
    def test_execute_model_request_with_valid_session(self):
        """
        """
        GASDKLibrary().register_sdk('default', tstdk)
        core_controller = GACoreController(garuda_uuid='test-garuda', redis_info={'host': '127.0.0.1', 'port': 6379, 'db': 6},
                                           additional_controller_classes=[AdditionalController], authentication_plugins=[FakeAuthPlugin()])

        request = GARequest(action=GARequest.ACTION_CREATE)
        request.resources = [GAResource(name='enterprise', value=None)]
        request.token = 'toto'

        with patch.object(core_controller.sessions_controller, 'get_session', return_value=GASession(garuda_uuid='test-garuda', root_object=tstdk.GARoot())):
            result = core_controller.execute_model_request(request)
            self.assertEquals(result.__class__, GAResponseFailure)  # nothing exists that's fine
Example #4
0
    def test_execute_model_request_with_invalid_session(self):
        """
        """
        GASDKLibrary().register_sdk('default', tstdk)
        core_controller = GACoreController(garuda_uuid='test-garuda', redis_info={'host': '127.0.0.1', 'port': 6379, 'db': 6},
                                           additional_controller_classes=[AdditionalController])

        request = GARequest(action=GARequest.ACTION_CREATE)
        request.resources = [GAResource(name='enterprise', value=None)]

        with patch.object(core_controller.sessions_controller, 'get_session', return_value=None):
            with patch.object(core_controller.sessions_controller, 'get_session', return_value=None):
                with patch.object(FakeAuthPlugin, 'authenticate', return_value=None):
                    result = core_controller.execute_model_request(request)
                    self.assertEquals(result.__class__, GAResponseFailure)
                    self.assertEquals(result.content[0].type, GAError.TYPE_UNAUTHORIZED)