Example #1
0
 def create_app(self):
     app = api.create_app(
         WEBSERVICES={
             'http://localhost:5005/': '/test_webservice',
             'http://127.0.0.1:5005/': '/test_webservice2',
             'adsws.tests.sample_microservice.app': '/test_webservice3'
         },
         RATELIMIT_GROUPS={
             'search': {
                 'limits': [6, 10],
                 'patterns': [
                     '/test_webservice2/LOW_RATE_LIMIT',
                     '/test_webservice2/.*', '/test_webservice3/.*'
                 ]
             }
         },
         WEBSERVICES_PUBLISH_ENDPOINT='resources',
         SQLALCHEMY_BINDS=None,
         SQLALCHEMY_DATABASE_URI='sqlite://',
         WTF_CSRF_ENABLED=False,
         TESTING=False,
         DEBUG=False,
         SITE_SECURE_URL='http://localhost',
         SECURITY_POST_LOGIN_VIEW='/postlogin',
         SECURITY_REGISTER_BLUEPRINT=True,
         SHOULD_NOT_OVERRIDE='parent',
         RATELIMIT_KEY_PREFIX='unittest.LocalDiscoverer.{}'.format(
             time.time()),
     )
     self._count = 6
     return app
Example #2
0
 def create_app(self):
     app = api.create_app(
         SQLALCHEMY_DATABASE_URI='sqlite://',
         SQLALCHEMY_BINDS=None,
         CORS_DOMAINS=['http://localhost', 'localhost:5000', 'localhost'],
         CORS_HEADERS=['content-type', 'X-BB-Api-Client-Version',
                       'Authorization', 'Accept', 'foo'],
         CORS_METHODS=['GET', 'OPTIONS', 'POST', 'PUT'],
         WEBSERVICES={},
         )
     return app
Example #3
0
 def create_app(self):
     app = api.create_app(
         SQLALCHEMY_DATABASE_URI='sqlite://',
         SQLALCHEMY_BINDS=None,
         CORS_DOMAINS=['http://localhost', 'localhost:5000', 'localhost'],
         CORS_HEADERS=[
             'content-type', 'X-BB-Api-Client-Version', 'Authorization',
             'Accept', 'foo'
         ],
         CORS_METHODS=['GET', 'OPTIONS', 'POST', 'PUT'],
         WEBSERVICES={},
     )
     return app
Example #4
0
 def create_app(self):
     app = api.create_app(
         WEBSERVICES={},
         SQLALCHEMY_BINDS=None,
         SQLALCHEMY_DATABASE_URI="sqlite://",
         WTF_CSRF_ENABLED=False,
         TESTING=False,
         DEBUG=False,
         SITE_SECURE_URL="http://localhost",
         SECURITY_POST_LOGIN_VIEW="/postlogin",
         SECURITY_REGISTER_BLUEPRINT=True,
         SHOULD_NOT_OVERRIDE="parent",
         RATELIMITER_KEY_PREFIX="unittest.LocalDiscoverer.{}".format(time.time()),
     )
     return app
Example #5
0
 def create_app(self):
     app = api.create_app(
         WEBSERVICES={},
         SQLALCHEMY_BINDS=None,
         SQLALCHEMY_DATABASE_URI='sqlite://',
         WTF_CSRF_ENABLED=False,
         TESTING=False,
         DEBUG=False,
         SITE_SECURE_URL='http://localhost',
         SECURITY_POST_LOGIN_VIEW='/postlogin',
         SECURITY_REGISTER_BLUEPRINT=True,
         SHOULD_NOT_OVERRIDE="parent",
         RATELIMIT_KEY_PREFIX='unittest.LocalDiscoverer.{}'.format(
             time.time()),
     )
     return app
Example #6
0
 def create_app(self):
     app = api.create_app(
         WEBSERVICES={'consul://test_webservice.service': '/test_webservice'},
         WEBSERVICES_PUBLISH_ENDPOINT='resources',
         SQLALCHEMY_BINDS=None,
         SQLALCHEMY_DATABASE_URI='sqlite://',
         WTF_CSRF_ENABLED=False,
         TESTING=False,
         DEBUG=False,
         SITE_SECURE_URL='http://localhost',
         SECURITY_POST_LOGIN_VIEW='/postlogin',
         SECURITY_REGISTER_BLUEPRINT=True,
         SHOULD_NOT_OVERRIDE='parent',
         RATELIMIT_KEY_PREFIX='unittest.LocalDiscoverer.{}'.format(
             time.time()),
     )
     return app
Example #7
0
 def create_app(self):
     app = api.create_app(
         WEBSERVICES={
             'adsws.tests.sample_microservice.app': '/test_webservice'
         },
         WEBSERVICES_PUBLISH_ENDPOINT='resources',
         SQLALCHEMY_BINDS=None,
         SQLALCHEMY_DATABASE_URI='sqlite://',
         WTF_CSRF_ENABLED=False,
         TESTING=False,
         DEBUG=False,
         SITE_SECURE_URL='http://localhost',
         SECURITY_POST_LOGIN_VIEW='/postlogin',
         SECURITY_REGISTER_BLUEPRINT=True,
         SHOULD_NOT_OVERRIDE="parent",
         RATELIMIT_KEY_PREFIX='unittest.LocalDiscoverer.{}'.format(
             time.time()),
     )
     return app
Example #8
0
from adsws import frontend
from adsws import benchmark

def get_resources(*apps):
    r = {}
    for _container in apps:
        app = _container['app']
        mnt = _container['mount']
        r[app.name] = {}
        r[app.name]['endpoints'] = []
        r[app.name]['base'] = mnt
        for rule in app.url_map.iter_rules():
            r[app.name]['endpoints'].append(rule.rule)
    return r

API = dict(mount='/v1', app=api.create_app())
ACCOUNTS = dict(mount='/v1/accounts', app=accounts.create_app())
FEEDBACK = dict(mount='/v1/feedback', app=feedback.create_app())
BENCHMARK = dict(mount='/benchmark', app=benchmark.create_app())

resources = get_resources(API, ACCOUNTS, FEEDBACK)

application = DispatcherMiddleware(frontend.create_app(resources=resources), {
    API['mount']: API['app'],
    ACCOUNTS['mount']: ACCOUNTS['app'],
    FEEDBACK['mount']: FEEDBACK['app'],
    BENCHMARK['mount']: BENCHMARK['app'],
})

if __name__ == "__main__":
    run_simple('0.0.0.0', 5000, application, use_reloader=False, use_debugger=True)