File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -95,3 +95,39 @@ def test_device_flow_authorization_initiation(self):
9595 "device_code" : "abc" ,
9696 "interval" : 5 ,
9797 }
98+
99+ @mock .patch (
100+ "oauthlib.oauth2.rfc8628.endpoints.device_authorization.generate_token" ,
101+ lambda : "abc" ,
102+ )
103+ def test_device_polling_interval_can_be_changed (self ):
104+ """
105+ Tests the device polling rate(interval) can be changed to something other than the default
106+ of 5 seconds.
107+ """
108+
109+ self .oauth2_settings .OAUTH_DEVICE_VERIFICATION_URI = "example.com/device"
110+ self .oauth2_settings .OAUTH_DEVICE_USER_CODE_GENERATOR = lambda : "xyz"
111+
112+ self .oauth2_settings .DEVICE_FLOW_INTERVAL = 10
113+
114+ request_data : dict [str , str ] = {
115+ "client_id" : self .application .client_id ,
116+ }
117+ request_as_x_www_form_urlencoded : str = urlencode (request_data )
118+
119+ response : django .http .response .JsonResponse = self .client .post (
120+ reverse ("oauth2_provider:device-authorization" ),
121+ data = request_as_x_www_form_urlencoded ,
122+ content_type = "application/x-www-form-urlencoded" ,
123+ )
124+
125+ assert response .status_code == 200
126+
127+ assert response .json () == {
128+ "verification_uri" : "example.com/device" ,
129+ "expires_in" : 1800 ,
130+ "user_code" : "xyz" ,
131+ "device_code" : "abc" ,
132+ "interval" : 10 ,
133+ }
You can’t perform that action at this time.
0 commit comments