def _assert_success(self, data, expected_scopes): form = AccessTokenExchangeForm(request=self.request, data=data) self.assertTrue(form.is_valid()) self.assertEqual(form.cleaned_data["user"], self.user) self.assertEqual(form.cleaned_data["client"], self.oauth_client) self.assertEqual(scope.to_names(form.cleaned_data["scope"]), expected_scopes)
def post(self, request, _backend): form = AccessTokenExchangeForm(request=request, data=request.POST) if not form.is_valid(): return self.error_response(form.errors) user = form.cleaned_data["user"] scope = form.cleaned_data["scope"] client = form.cleaned_data["client"] if constants.SINGLE_ACCESS_TOKEN: edx_access_token = self.get_access_token(request, user, scope, client) else: edx_access_token = self.create_access_token(request, user, scope, client) return self.access_token_response(edx_access_token)
def _assert_error(self, data, expected_error, expected_error_description): form = AccessTokenExchangeForm(request=self.request, data=data) self.assertEqual( form.errors, { "error": expected_error, "error_description": expected_error_description }) self.assertNotIn("partial_pipeline", self.request.session)
def post(self, request, _backend): form = AccessTokenExchangeForm(request=request, data=request.POST) if not form.is_valid(): return self.error_response(form.errors) user = form.cleaned_data["user"] scope = form.cleaned_data["scope"] client = form.cleaned_data["client"] if constants.SINGLE_ACCESS_TOKEN: edx_access_token = self.get_access_token(request, user, scope, client) else: edx_access_token = self.create_access_token( request, user, scope, client) return self.access_token_response(edx_access_token)