def decorated_function(*args, **kwargs): """ definition of login_required """ bearer_token = request.headers.get('Authorization') if not bearer_token: return auth_required() auth_token = bearer_token.split()[1] if not auth_token: return auth_required() # validate auth_token response, status_code = validate_with_qubeship_auth(auth_token) if status_code != 200: return auth_required() userinfo = json.loads(response) if userinfo['type'] != "org": return unsupported_token() is_system_user = userinfo['is_system_user'] \ if 'is_system_user' in userinfo else False auth_context = AuthContext(userinfo['tenant']['id'], userinfo['tenant']['name'], userinfo['tenant']['orgs'][0]['id'], userinfo['tenant']['orgs'][0]['name'], userinfo['id'], 'auth_not_implemented', is_system_user) kwargs['authcontext'] = {'context': auth_context} return f(*args, **kwargs)
def setUp(self): context = AuthContext("23432523452345", "tenantname", "987656789765670", "orgname", "1009009009988", "username", False) self.kate6Service = kate6Service(context) self.kate6_api_model = self.createTestModelData() self.kate6_data = self.setupDatabaseRecords(self.kate6_api_model) self.kate6_someoneelses = \ self.setupDatabaseRecords(self.kate6_api_model) self.kate6_someoneelses.tenantId = "123432523452345" with patch('mongomock.write_concern.WriteConcern.__init__', return_value=None): self.kate6_someoneelses.save() self.kate6_api_model_put_description \ = self.createTestModelDataDescription() self.test_data_collection = [self.kate6_data]
def setUp(self): context = AuthContext("23432523452345", "tenantname", "987656789765670", "orgname", "1009009009988", "username", False) self.artifactsService = ArtifactsService(context) self.artifacts_api_model = self.createTestModelData() self.artifacts_data = \ self.setupDatabaseRecords(PROJECT_ID, ITERATION_ID, self.artifacts_api_model) self.artifacts_someoneelses = \ self.setupDatabaseRecords(SOME_OTHER_PROJECT_ID, ITERATION_ID, self.artifacts_api_model) self.artifacts_someoneelses.tenantId = "123432523452345" with patch('mongomock.write_concern.WriteConcern.__init__', return_value=None): self.artifacts_someoneelses.save() self.artifacts_api_model_for_update \ = self.createTestModelDataUpdate() self.test_data_collection = [self.artifacts_data]