Ejemplo n.º 1
0
    def run():
        responses.mock.start()
        StackInABox.register_service(AdvancedService())
        stackinabox.util_responses.responses_registration('localhost')

        res = requests.get('http://localhost/advanced/')
        assert res.status_code == 200
        assert res.text == 'Hello'

        res = requests.get('http://localhost/advanced/h')
        assert res.status_code == 200
        assert res.text == 'Good-Bye'

        expected_result = {
            'bob': 'bob: Good-Bye alice',
            'alice': 'alice: Good-Bye bob',
            'joe': 'joe: Good-Bye jane'
        }
        res = requests.get('http://localhost/advanced/g?bob=alice;'
                           'alice=bob&joe=jane')
        assert res.status_code == 200
        assert res.json() == expected_result

        StackInABox.reset_services()

        responses.mock.stop()
        responses.mock.reset()
Ejemplo n.º 2
0
    def run():
        StackInABox.reset_services()
        StackInABox.register_service(HelloService())
        stackinabox.util.responses.registration('localhost')

        res = requests.get('http://localhost/hello/')
        assert res.status_code == 200
        assert res.text == 'Hello'
Ejemplo n.º 3
0
    def run():
        StackInABox.reset_services()
        StackInABox.register_service(HelloService())
        stackinabox.util_responses.responses_registration('localhost')

        res = requests.get('http://localhost/hello/')
        assert res.status_code == 200
        assert res.text == 'Hello'
Ejemplo n.º 4
0
            def run():
                responses.mock.start()

                StackInABox.reset_services()
                for service in self.services.values():
                    StackInABox.register_service(service)
                responses_registration(self.uri)
                return_value = fn(*args_finalized, **kwargs)
                StackInABox.reset_services()

                responses.mock.stop()
                responses.mock.reset()
Ejemplo n.º 5
0
            def run():
                responses.mock.start()

                StackInABox.reset_services()
                for service in self.services.values():
                    StackInABox.register_service(service)
                responses_registration(self.uri)
                return_value = fn(*args_finalized, **kwargs)
                StackInABox.reset_services()

                responses.mock.stop()
                responses.mock.reset()
Ejemplo n.º 6
0
        def wrapped(*args, **kwargs):
            args_copy = list(args)
            for arg in self.args:
                args_copy.append(arg)
            args_finalized = tuple(args_copy)
            kwargs.update(self.kwargs)

            if self.enable_service_access is not None:
                kwargs[self.enable_service_access] = self.services

            with requests_mock_activate():
                if self.session is not None:
                    kwargs[self.session] = requests.Session()

                    StackInABox.reset_services()
                    for service in self.services.values():
                        StackInABox.register_service(service)
                    requests_mock_session_registration(
                        self.uri,
                        kwargs[self.session]
                    )
                    return_value = fn(*args_finalized, **kwargs)
                    StackInABox.reset_services()

                else:
                    StackInABox.reset_services()
                    for service in self.services.values():
                        StackInABox.register_service(service)
                    requests_mock_registration(self.uri)
                    return_value = fn(*args_finalized, **kwargs)
                    StackInABox.reset_services()

            return return_value
Ejemplo n.º 7
0
        def wrapped(*args, **kwargs):
            args_copy = list(args)
            for arg in self.args:
                args_copy.append(arg)
            args_finalized = tuple(args_copy)
            kwargs.update(self.kwargs)

            if self.enable_service_access is not None:
                kwargs[self.enable_service_access] = self.services

            with requests_mock_activate():
                if self.session is not None:
                    kwargs[self.session] = requests.Session()

                    StackInABox.reset_services()
                    for service in self.services.values():
                        StackInABox.register_service(service)
                    requests_mock_session_registration(self.uri,
                                                       kwargs[self.session])
                    return_value = fn(*args_finalized, **kwargs)
                    StackInABox.reset_services()

                else:
                    StackInABox.reset_services()
                    for service in self.services.values():
                        StackInABox.register_service(service)
                    requests_mock_registration(self.uri)
                    return_value = fn(*args_finalized, **kwargs)
                    StackInABox.reset_services()

            return return_value
Ejemplo n.º 8
0
    def run(use_deprecated):
        responses.mock.start()
        StackInABox.register_service(AdvancedService())
        if use_deprecated:
            stackinabox.util.responses.responses_registration('localhost')
        else:
            stackinabox.util.responses.registration('localhost')

        res = requests.get('http://localhost/advanced/')
        assert res.status_code == 200
        assert res.text == 'Hello'

        res = requests.get('http://localhost/advanced/h')
        assert res.status_code == 200
        assert res.text == 'Good-Bye'

        expected_result = {
            'bob': 'bob: Good-Bye alice',
            'alice': 'alice: Good-Bye bob',
            'joe': 'joe: Good-Bye jane'
        }
        res = requests.get('http://localhost/advanced/g?bob=alice;'
                           'alice=bob&joe=jane')
        assert res.status_code == 200
        assert res.json() == expected_result

        res = requests.get('http://localhost/advanced/1234567890')
        assert res.status_code == 200
        assert res.text == 'okay'

        res = requests.get('http://localhost/advanced/_234567890')
        assert res.status_code == 595

        res = requests.put('http://localhost/advanced/h')
        assert res.status_code == 405

        res = requests.put('http://localhost/advanced2/i')
        assert res.status_code == 597

        StackInABox.reset_services()

        responses.mock.stop()
        responses.mock.reset()
Ejemplo n.º 9
0
    def run():
        responses.mock.start()
        StackInABox.register_service(AdvancedService())
        stackinabox.util.responses.registration('localhost')

        res = requests.get('http://localhost/advanced/')
        assert res.status_code == 200
        assert res.text == 'Hello'

        res = requests.get('http://localhost/advanced/h')
        assert res.status_code == 200
        assert res.text == 'Good-Bye'

        expected_result = {
            'bob': 'bob: Good-Bye alice',
            'alice': 'alice: Good-Bye bob',
            'joe': 'joe: Good-Bye jane'
        }
        res = requests.get('http://localhost/advanced/g?bob=alice;'
                           'alice=bob&joe=jane')
        assert res.status_code == 200
        assert res.json() == expected_result

        res = requests.get('http://localhost/advanced/1234567890')
        assert res.status_code == 200
        assert res.text == 'okay'

        res = requests.get('http://localhost/advanced/_234567890')
        assert res.status_code == 595

        res = requests.put('http://localhost/advanced/h')
        assert res.status_code == 405

        res = requests.put('http://localhost/advanced2/i')
        assert res.status_code == 597

        StackInABox.reset_services()

        responses.mock.stop()
        responses.mock.reset()
Ejemplo n.º 10
0
    def test_user_listing(self):
        stackinabox.util_httpretty.httpretty_registration('localhost')

        neo_tenant_id = self.keystone.backend.add_tenant(tenantname='neo',
                                                         description='The One')
        tom = self.keystone.backend.add_user(neo_tenant_id,
                                             'tom',
                                             '*****@*****.**',
                                             'bluepill',
                                             'iamnottheone',
                                             enabled=True)
        self.keystone.backend.add_user_role_by_rolename(
            neo_tenant_id, tom, 'identity:user-admin')

        self.keystone.backend.add_token(neo_tenant_id, tom)
        user_data = self.keystone.backend.get_token_by_userid(tom)
        self.headers['x-auth-token'] = user_data['token']
        res = requests.get('http://localhost/keystone/v2.0/users',
                           headers=self.headers)
        print(res.text)
        self.assertEqual(res.status_code, 200)
        user_data = res.json()

        self.assertEqual(len(user_data['users']), 1)

        self.keystone.backend.add_user(neo_tenant_id,
                                       'neo',
                                       '*****@*****.**',
                                       'redpill',
                                       'iamtheone',
                                       enabled=True)

        res = requests.get('http://localhost/keystone/v2.0/users',
                           headers=self.headers)
        self.assertEqual(res.status_code, 200)
        user_data = res.json()

        self.assertEqual(len(user_data['users']), 2)
        StackInABox.reset_services()
Ejemplo n.º 11
0
        def wrapped(*args, **kwargs):
            args_copy = list(args)
            for arg in self.args:
                args_copy.append(arg)
            args_finalized = tuple(args_copy)
            kwargs.update(self.kwargs)

            if self.enable_service_access is not None:
                kwargs[self.enable_service_access] = self.services

            httpretty.reset()
            httpretty.enable()

            for service in self.services.values():
                StackInABox.register_service(service)
            httpretty_registration(self.uri)
            return_value = fn(*args_finalized, **kwargs)
            StackInABox.reset_services()

            httpretty.disable()
            httpretty.reset()

            return return_value
Ejemplo n.º 12
0
        def wrapped(*args, **kwargs):
            args_copy = list(args)
            for arg in self.args:
                args_copy.append(arg)
            args_finalized = tuple(args_copy)
            kwargs.update(self.kwargs)

            if self.enable_service_access is not None:
                kwargs[self.enable_service_access] = self.services

            httpretty.reset()
            httpretty.enable()

            for service in self.services.values():
                StackInABox.register_service(service)
            httpretty_registration(self.uri)
            return_value = fn(*args_finalized, **kwargs)
            StackInABox.reset_services()

            httpretty.disable()
            httpretty.reset()

            return return_value
Ejemplo n.º 13
0
 def tearDown(self):
     super(TestRequestsMockBasic, self).tearDown()
     StackInABox.reset_services()
     self.session.close()
Ejemplo n.º 14
0
 def tearDown(self):
     super(TestHttprettyAdvanced, self).tearDown()
     StackInABox.reset_services()
Ejemplo n.º 15
0
 def tearDown(self):
     super(TestServiceRouteRegistration, self).tearDown()
     StackInABox.reset_services()
 def tearDown(self):
     super(TestKeystoneV2UserAddCredentials, self).tearDown()
     StackInABox.reset_services()
Ejemplo n.º 17
0
 def tearDown(self):
     super(TestKeystoneV2AuthBase, self).tearDown()
     StackInABox.reset_services()
Ejemplo n.º 18
0
 def tearDown(self):
     super(TestMetrics, self).tearDown()
     StackInABox.reset_services()
Ejemplo n.º 19
0
 def tearDown(self):
     super(TestHttprettyKeystone, self).tearDown()
     StackInABox.reset_services()
     self.session.close()
 def tearDown(self):
     super(TestKeystoneV2Tenants, self).tearDown()
     StackInABox.reset_services()
Ejemplo n.º 21
0
 def tearDown(self):
     super(TestHttprettyAdvanced, self).tearDown()
     StackInABox.reset_services()
Ejemplo n.º 22
0
 def tearDown(self):
     """
     Test Teardown
     """
     StackInABox.reset_services()
Ejemplo n.º 23
0
 def tearDown(self):
     super(TestRequestMockAdvanced, self).tearDown()
     StackInABox.reset_services()
     self.session.close()
Ejemplo n.º 24
0
 def tearDown(self):
     super(TestRequestsMockBasic, self).tearDown()
     StackInABox.reset_services()
     self.session.close()
Ejemplo n.º 25
0
 def tearDown(self):
     super(TestHttprettyKeystone, self).tearDown()
     StackInABox.reset_services()
 def tearDown(self):
     super(TestKeystoneV2UserListing, self).tearDown()
     StackInABox.reset_services()
Ejemplo n.º 27
0
 def tearDown(self):
     super(TestMetrics, self).tearDown()
     StackInABox.reset_services()
Ejemplo n.º 28
0
 def tearDown(self):
     super(TestServiceRouteRegistration, self).tearDown()
     StackInABox.reset_services()
Ejemplo n.º 29
0
 def tearDown(self):
     super(TestRequestMockAdvanced, self).tearDown()
     StackInABox.reset_services()
     self.session.close()