@@ -686,6 +686,32 @@ def test_namespace(self):
686
686
def test_namespace_fails (self ):
687
687
self .assertRaises (ValueError , binding .namespace , sharing = "gobble" )
688
688
689
+ class TestBasicAuthentication (unittest .TestCase ):
690
+ def setUp (self ):
691
+ self .opts = testlib .parse ([], {}, ".splunkrc" )
692
+ opts = self .opts .kwargs .copy ()
693
+ opts ["basic" ] = True
694
+ opts ["username" ] = self .opts .kwargs ["username" ]
695
+ opts ["password" ] = self .opts .kwargs ["password" ]
696
+
697
+ self .context = binding .connect (** opts )
698
+ import splunklib .client as client
699
+ service = client .Service (** opts )
700
+
701
+ if getattr (unittest .TestCase , 'assertIsNotNone' , None ) is None :
702
+ def assertIsNotNone (self , obj , msg = None ):
703
+ if obj is None :
704
+ raise self .failureException , (msg or '%r is not None' % obj )
705
+
706
+ def test_basic_in_auth_headers (self ):
707
+ self .assertIsNotNone (self .context ._auth_headers )
708
+ self .assertNotEqual (self .context ._auth_headers , [])
709
+ self .assertEqual (len (self .context ._auth_headers ), 1 )
710
+ self .assertEqual (len (self .context ._auth_headers ), 1 )
711
+ self .assertEqual (self .context ._auth_headers [0 ][0 ], "Authorization" )
712
+ self .assertEqual (self .context ._auth_headers [0 ][1 ][:6 ], "Basic " )
713
+ self .assertEqual (self .context .get ("/services" ).status , 200 )
714
+
689
715
class TestTokenAuthentication (BindingTestCase ):
690
716
def test_preexisting_token (self ):
691
717
token = self .context .token
0 commit comments