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