Ejemplo n.º 1
0
 def _parse_client(self, values, conn):
     application_apikey = values.get('client')
     if not application_apikey:
         raise errors.MissingParameterError('client')
     self.application_id = lookup_application_id_by_apikey(conn, application_apikey)
     if not self.application_id:
         raise errors.InvalidAPIKeyError()
Ejemplo n.º 2
0
def check_app_api_key(config, db, application_apikey):
    app_db = db.get_app_db(read_only=True)
    application_id = lookup_application_id_by_apikey(app_db,
                                                     application_apikey,
                                                     only_active=True)
    if not application_id:
        if check_demo_client_api_key(config.website.secret,
                                     application_apikey):
            application_id = DEMO_APPLICATION_ID
    return application_id
Ejemplo n.º 3
0
 def _parse_client(self, values, conn):
     application_apikey = values.get('client')
     if not application_apikey:
         raise errors.MissingParameterError('client')
     self.application_id = lookup_application_id_by_apikey(conn, application_apikey, only_active=True)
     if not self.application_id:
         if check_demo_client_api_key(self.config.website.secret, application_apikey):
             self.application_id = DEMO_APPLICATION_ID
         else:
             logger.error("Invalid API key %s", application_apikey)
             raise errors.InvalidAPIKeyError()
     self.application_version = values.get('clientversion')
Ejemplo n.º 4
0
 def _parse_client(self, values, conn):
     application_apikey = values.get('client')
     if not application_apikey:
         raise errors.MissingParameterError('client')
     self.application_id = lookup_application_id_by_apikey(
         conn, application_apikey, only_active=True)
     if not self.application_id:
         if check_demo_client_api_key(self.config.website.secret,
                                      application_apikey):
             self.application_id = DEMO_APPLICATION_ID
         else:
             logger.error("Invalid API key %s", application_apikey)
             raise errors.InvalidAPIKeyError()
     self.application_version = values.get('clientversion')
def test_lookup_application_id_by_apikey(conn):
    id = lookup_application_id_by_apikey(conn, 'app1key')
    assert_equals(1, id)
    id = lookup_application_id_by_apikey(conn, 'foooo')
    assert_equals(None, id)
def test_lookup_application_id_by_apikey(conn):
    id = lookup_application_id_by_apikey(conn, 'app1key')
    assert_equals(1, id)
    id = lookup_application_id_by_apikey(conn, 'foooo')
    assert_equals(None, id)