@@ -451,8 +451,6 @@ def setUp(self):
451451 self .gl = Gitlab (
452452 "http://localhost" ,
453453 private_token = "private_token" ,
454- email = "testuser@test.com" ,
455- password = "testpassword" ,
456454 ssl_verify = True ,
457455 api_version = 4 ,
458456 )
@@ -465,66 +463,7 @@ def test_pickability(self):
465463 self .assertTrue (hasattr (unpickled , "_objects" ))
466464 self .assertEqual (unpickled ._objects , original_gl_objects )
467465
468- def test_credentials_auth_nopassword (self ):
469- self .gl .email = None
470- self .gl .password = None
471-
472- @urlmatch (
473- scheme = "http" , netloc = "localhost" , path = "/api/v4/session" , method = "post"
474- )
475- def resp_cont (url , request ):
476- headers = {"content-type" : "application/json" }
477- content = '{"message": "message"}' .encode ("utf-8" )
478- return response (404 , content , headers , None , 5 , request )
479-
480- with HTTMock (resp_cont ):
481- self .assertRaises (GitlabHttpError , self .gl ._credentials_auth )
482-
483- def test_credentials_auth_notok (self ):
484- @urlmatch (
485- scheme = "http" , netloc = "localhost" , path = "/api/v4/session" , method = "post"
486- )
487- def resp_cont (url , request ):
488- headers = {"content-type" : "application/json" }
489- content = '{"message": "message"}' .encode ("utf-8" )
490- return response (404 , content , headers , None , 5 , request )
491-
492- with HTTMock (resp_cont ):
493- self .assertRaises (GitlabHttpError , self .gl ._credentials_auth )
494-
495- def test_auth_with_credentials (self ):
496- self .gl .private_token = None
497- self .test_credentials_auth (callback = self .gl .auth )
498-
499- def test_auth_with_token (self ):
500- self .test_token_auth (callback = self .gl .auth )
501-
502- def test_credentials_auth (self , callback = None ):
503- if callback is None :
504- callback = self .gl ._credentials_auth
505- token = "credauthtoken"
506- id_ = 1
507- expected = {"PRIVATE-TOKEN" : token }
508-
509- @urlmatch (
510- scheme = "http" , netloc = "localhost" , path = "/api/v4/session" , method = "post"
511- )
512- def resp_cont (url , request ):
513- headers = {"content-type" : "application/json" }
514- content = '{{"id": {0:d}, "private_token": "{1:s}"}}' .format (
515- id_ , token
516- ).encode ("utf-8" )
517- return response (201 , content , headers , None , 5 , request )
518-
519- with HTTMock (resp_cont ):
520- callback ()
521- self .assertEqual (self .gl .private_token , token )
522- self .assertDictEqual (expected , self .gl .headers )
523- self .assertEqual (self .gl .user .id , id_ )
524-
525466 def test_token_auth (self , callback = None ):
526- if callback is None :
527- callback = self .gl ._token_auth
528467 name = "username"
529468 id_ = 1
530469
@@ -537,7 +476,7 @@ def resp_cont(url, request):
537476 return response (200 , content , headers , None , 5 , request )
538477
539478 with HTTMock (resp_cont ):
540- callback ()
479+ self . gl . auth ()
541480 self .assertEqual (self .gl .user .username , name )
542481 self .assertEqual (self .gl .user .id , id_ )
543482 self .assertEqual (type (self .gl .user ), CurrentUser )
0 commit comments