Example #1
0
def main(argv=sys.argv[1:]):
    available_services = BACKENDS.keys()

    parser = argparse.ArgumentParser()
    parser.add_argument('service',
                        type=str,
                        choices=available_services,
                        help='Choose which mechanism you want to run')
    parser.add_argument('-H',
                        '--host',
                        type=str,
                        help='Which host to bind',
                        default='0.0.0.0')
    parser.add_argument('-p',
                        '--port',
                        type=int,
                        help='Port number to use for connection',
                        default=5000)

    args = parser.parse_args(argv)

    configure_urls(args.service)

    app.testing = True
    app.run(host=args.host, port=args.port)
Example #2
0
def main(argv=sys.argv[1:]):
    available_services = BACKENDS.keys()

    parser = argparse.ArgumentParser()
    parser.add_argument(
        'service', type=str,
        choices=available_services,
        help='Choose which mechanism you want to run')
    parser.add_argument(
        '-H', '--host', type=str,
        help='Which host to bind',
        default='0.0.0.0')
    parser.add_argument(
        '-p', '--port', type=int,
        help='Port number to use for connection',
        default=5000)

    args = parser.parse_args(argv)

    configure_urls(args.service)

    app.testing = True

    from tornado.wsgi import WSGIContainer
    from tornado.httpserver import HTTPServer
    from tornado.ioloop import IOLoop

    http_server = HTTPServer(WSGIContainer(app))
    http_server.listen(args.port)
    IOLoop.instance().start()
Example #3
0
 def reset(self):
     from moto.backends import BACKENDS
     for name, backends in BACKENDS.items():
         if name == "moto_api":
             continue
         for region_name, backend in backends.items():
             backend.reset()
     self.__init__()
Example #4
0
 def reset(self):
     from moto.backends import BACKENDS
     for name, backends in BACKENDS.items():
         if name == "moto_api":
             continue
         for region_name, backend in backends.items():
             backend.reset()
     self.__init__()
Example #5
0
    def get_backend_for_host(self, host):
        if self.service:
            return self.service

        for backend_name, backend in BACKENDS.items():
            for url_base in backend.url_bases:
                if re.match(url_base, 'http://%s' % host):
                    return backend_name

        raise RuntimeError('Invalid host: "%s"' % host)
Example #6
0
    def get_backend_for_host(self, host):
        if self.service:
            return self.service

        for backend_name, backend in BACKENDS.items():
            for url_base in backend.url_bases:
                if re.match(url_base, 'http://%s' % host):
                    return backend_name

        raise RuntimeError('Invalid host: "%s"' % host)
Example #7
0
    def get_backend_for_host(self, host):
        if host == "moto_api":
            return host

        if self.service:
            return self.service

        if host in BACKENDS:
            return host

        for backend_name, backend in BACKENDS.items():
            for url_base in list(backend.values())[0].url_bases:
                if re.match(url_base, "http://%s" % host):
                    return backend_name
Example #8
0
def main(argv=sys.argv[1:]):
    available_services = BACKENDS.keys()

    parser = argparse.ArgumentParser()
    parser.add_argument("service", type=str, choices=available_services, help="Choose which mechanism you want to run")
    parser.add_argument("-H", "--host", type=str, help="Which host to bind", default="0.0.0.0")
    parser.add_argument("-p", "--port", type=int, help="Port number to use for connection", default=5000)

    args = parser.parse_args(argv)

    configure_urls(args.service)

    app.testing = True
    app.run(host=args.host, port=args.port)
Example #9
0
    def get_backend_for_host(self, host):
        if host == 'moto_api':
            return host

        if self.service:
            return self.service

        if host in BACKENDS:
            return host

        for backend_name, backend in BACKENDS.items():
            for url_base in list(backend.values())[0].url_bases:
                if re.match(url_base, 'http://%s' % host):
                    return backend_name

        raise RuntimeError('Invalid host: "%s"' % host)
Example #10
0
from boto3 import Session
from cloud_inquisitor.config import dbconfig
from cloud_inquisitor.constants import NS_CINQ_TEST, ROLE_ADMIN
from moto.backends import BACKENDS
from tests.libs.var_const import CINQ_TEST_MOCKING_SERVICE_HOST, CINQ_TEST_MOCKING_SERVICE_PORTS

service_lut = {
    k: '{}:{}'.format(CINQ_TEST_MOCKING_SERVICE_HOST, v)
    for (k, v) in dict(zip(BACKENDS.keys(), CINQ_TEST_MOCKING_SERVICE_PORTS)).items()
}


class MockSession(Session):
    def client(self, service_name, region_name=None, api_version=None,
               use_ssl=True, verify=None, endpoint_url=None,
               aws_access_key_id=None, aws_secret_access_key=None,
               aws_session_token=None, config=None):
        """
        Patch boto3.session.client so all requests will be redirected to AWS Mocking services
        """
        return super().client(
            service_name=service_name,
            region_name=region_name,
            api_version=api_version,
            use_ssl=False,
            verify=False,
            endpoint_url='http://{}'.format(service_lut[service_name]),
            aws_access_key_id='',
            aws_secret_access_key='',
            aws_session_token='',
            config=config