Example #1
0
    def test_execute_event_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)]

        session = GASession(garuda_uuid='test-garuda')
        session.root_object = NURESTRootObject()
        session.root_object.id = 'toto'

        with patch.object(core_controller.sessions_controller,
                          'get_session',
                          return_value=session):
            result = core_controller.execute_events_request(request)
            self.assertEquals(result[0].__class__, GASession)
            self.assertEquals(result[1], None)
Example #2
0
    def test_execute_event_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],
            authentication_plugins=[FakeAuthPlugin()])

        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):
            result = core_controller.execute_events_request(request)
            self.assertEquals(result[0], None)
            self.assertEquals(result[1].__class__, GAResponseFailure)
            self.assertEquals(len(result[1].content), 1)
            self.assertEquals(result[1].content[0].type,
                              GAError.TYPE_UNAUTHORIZED)
Example #3
0
    def test_execute_event_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], authentication_plugins=[FakeAuthPlugin()])

        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):
            result = core_controller.execute_events_request(request)
            self.assertEquals(result[0], None)
            self.assertEquals(result[1].__class__, GAResponseFailure)
            self.assertEquals(len(result[1].content), 1)
            self.assertEquals(result[1].content[0].type, GAError.TYPE_UNAUTHORIZED)
Example #4
0
    def test_execute_event_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)]

        session = GASession(garuda_uuid='test-garuda')
        session.root_object = NURESTRootObject()
        session.root_object.id = 'toto'

        with patch.object(core_controller.sessions_controller, 'get_session', return_value=session):
            result = core_controller.execute_events_request(request)
            self.assertEquals(result[0].__class__, GASession)
            self.assertEquals(result[1], None)