def _get_request(self): warnings.warn( '`request.REQUEST` is deprecated, use `request.GET` or ' '`request.POST` instead.', PendingDeprecationWarning, 2) if not hasattr(self, '_request'): self._request = datastructures.MergeDict(self.POST, self.GET) return self._request
def as_request(self): assert self.request_data, 'Could not construct an empty TestCase object' request = http.HttpRequest() data = self.request_data_dict request.path = data['path'] request.method = data['method'] request.path_info = data['path_info'] request._body = data['body'] request.META = data['headers'] request._encoding = data['encoding'] request._stream = StringIO() request._read_started = False request._post_parse_error = False request.resolver_match = None request._load_post_and_files() query_string = '%s&%s=1' % (data['query_string'], TEST_REQUEST_PARAM) request.GET = http.QueryDict(query_string, encoding=request.encoding) request.POST = getattr(request, '_post') request.FILES = getattr(request, '_files') request.COOKIES = http.parse_cookie( request.META.get('HTTP_COOKIE', b'')) request.REQUEST = datastructures.MergeDict(request.POST, request.GET) # extra attributes added by middlewares from django.contrib.auth.middleware import get_user engine = import_module(settings.SESSION_ENGINE) request.session = engine.SessionStore( request.COOKIES.get(settings.SESSION_COOKIE_NAME, None)) request.user = SimpleLazyObject(lambda: get_user(request)) return request
def auth_complete(self, *args, **kwargs): """Completes loging process, must return user instance""" # validate signature ts = int(self.data.get('ts', '')) sig = self.data.get('sig', '') self.validateSignature(ts, sig) # decrypt userData using AES iv = self.data.get('iv', '') userDataEnc = self.data.get('userData', '') userData = self.decrypt(userDataEnc, iv) userData = userData.replace('\"', '') userDataList = userData.split(',') userDataDict = {'username': userDataList[0]} userDataDict['first_name'] = userDataList[1] userDataDict['last_name'] = userDataList[2] userDataDict['email'] = userDataList[3] self.data = datastructures.MergeDict(self.data, userDataDict) if self.ID_KEY not in self.data: raise AuthMissingParameter(self, self.ID_KEY) kwargs.update({'response': self.data, 'backend': self}) return self.strategy.authenticate(*args, **kwargs)
def _get_request(self): if not hasattr(self, '_request'): self._request = datastructures.MergeDict(self.POST, self.GET) return self._request
def _get_request(This): if not hasattr(This, '_request'): This._request = datastructures.MergeDict(This.POST, This.GET) return This._request