@@ -306,3 +306,38 @@ func TestDeleteGrant(t *testing.T) {
306
306
t .Errorf ("OAuthAuthorizations.DeleteGrant returned error: %v" , err )
307
307
}
308
308
}
309
+
310
+ func TestAuthorizationsService_CreateImpersonation (t * testing.T ) {
311
+ setup ()
312
+ defer teardown ()
313
+
314
+ mux .HandleFunc ("/admin/users/u/authorizations" , func (w http.ResponseWriter , r * http.Request ) {
315
+ testMethod (t , r , "POST" )
316
+ fmt .Fprint (w , `{"id":1}` )
317
+ })
318
+
319
+ req := & AuthorizationRequest {Scopes : []Scope {ScopePublicRepo }}
320
+ got , _ , err := client .Authorizations .CreateImpersonation ("u" , req )
321
+ if err != nil {
322
+ t .Errorf ("Authorizations.CreateImpersonation returned error: %+v" , err )
323
+ }
324
+
325
+ want := & Authorization {ID : Int (1 )}
326
+ if ! reflect .DeepEqual (got , want ) {
327
+ t .Errorf ("Authorizations.CreateImpersonation returned %+v, want %+v" , * got .ID , * want .ID )
328
+ }
329
+ }
330
+
331
+ func TestAuthorizationsService_DeleteImpersonation (t * testing.T ) {
332
+ setup ()
333
+ defer teardown ()
334
+
335
+ mux .HandleFunc ("/admin/users/u/authorizations" , func (w http.ResponseWriter , r * http.Request ) {
336
+ testMethod (t , r , "DELETE" )
337
+ })
338
+
339
+ _ , err := client .Authorizations .DeleteImpersonation ("u" )
340
+ if err != nil {
341
+ t .Errorf ("Authorizations.DeleteImpersonation returned error: %+v" , err )
342
+ }
343
+ }
0 commit comments