MCPcopy
hub / github.com/authlib/authlib / test_oauth1_authorize

Function test_oauth1_authorize

tests/clients/test_django/test_oauth_client.py:64–92  ·  view source on GitHub ↗
(factory)

Source from the content-addressed store, hash-verified

62
63
64def test_oauth1_authorize(factory):
65 request = factory.get("/login")
66 request.session = factory.session
67
68 oauth = OAuth()
69 client = oauth.register(
70 "dev",
71 client_id="dev",
72 client_secret="dev",
73 request_token_url="https://provider.test/request-token",
74 api_base_url="https://resource.test/api",
75 access_token_url="https://provider.test/token",
76 authorize_url="https://provider.test/authorize",
77 )
78
79 with mock.patch("requests.sessions.Session.send") as send:
80 send.return_value = mock_send_value("oauth_token=foo&oauth_verifier=baz")
81
82 resp = client.authorize_redirect(request)
83 assert resp.status_code == 302
84 url = resp.get("Location")
85 assert "oauth_token=foo" in url
86
87 request2 = factory.get(url)
88 request2.session = request.session
89 with mock.patch("requests.sessions.Session.send") as send:
90 send.return_value = mock_send_value("oauth_token=a&oauth_token_secret=b")
91 token = client.authorize_access_token(request2)
92 assert token["oauth_token"] == "a"
93
94
95def test_oauth2_authorize(factory):

Callers

nothing calls this directly

Calls 7

registerMethod · 0.95
OAuthClass · 0.90
mock_send_valueFunction · 0.85
patchMethod · 0.80
getMethod · 0.45
authorize_redirectMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…