<s> import testlib <EOL> import logging <EOL> import splunklib . client as client <EOL> class Tests ( testlib . SDKTestCase ) : <EOL> def setUp ( self ) : <EOL> self . service = client . connect ( ** self . opts . kwargs ) <EOL> self . storage_passwords = self . service . storage_passwords <EOL> def tearDown ( self ) : <EOL> for sp in self . storage_passwords : <EOL> if "<STR_LIT>" in sp . username or "<STR_LIT>" in sp . realm : <EOL> sp . delete ( ) <EOL> def test_create ( self ) : <EOL> start_count = len ( self . storage_passwords ) <EOL> realm = testlib . tmpname ( ) <EOL> username = testlib . tmpname ( ) <EOL> p = self . storage_passwords . create ( "<STR_LIT>" , username , realm ) <EOL> self . assertEqual ( start_count + <NUM_LIT:1> , len ( self . storage_passwords ) ) <EOL> self . assertEqual ( p . realm , realm ) <EOL> self . assertEqual ( p . username , username ) <EOL> self . assertEqual ( p . clear_password , "<STR_LIT>" ) <EOL> self . assertEqual ( p . name , realm + "<STR_LIT::>" + username + "<STR_LIT::>" ) <EOL> p . delete ( ) <EOL> self . assertEqual ( start_count , len ( self . storage_passwords ) ) <EOL> def test_create_with_backslashes ( self ) : <EOL> start_count = len ( self . storage_passwords ) <EOL> realm = "<STR_LIT:\\>" + testlib . tmpname ( ) <EOL> username = "<STR_LIT:\\>" + testlib . tmpname ( ) <EOL> p = self . storage_passwords . create ( "<STR_LIT>" , username , realm ) <EOL> self . assertEqual ( start_count + <NUM_LIT:1> , len ( self . storage_passwords ) ) <EOL> self . assertEqual ( p . realm , realm ) <EOL> self . assertEqual ( p . username , username ) <EOL> self . assertEqual ( p . clear_password , "<STR_LIT>" ) <EOL> self . assertEqual ( p . name , "<STR_LIT:\\>" + realm + "<STR_LIT>" + username + "<STR_LIT::>" ) <EOL> p . delete ( ) <EOL> self . assertEqual ( start_count , len ( self . storage_passwords ) ) <EOL> def test_create_with_slashes ( self ) : <EOL> start_count = len ( self . storage_passwords ) <EOL> realm = "<STR_LIT:/>" + testlib . tmpname ( ) <EOL> username = "<STR_LIT:/>" + testlib . tmpname ( ) <EOL> p = self . storage_passwords . create ( "<STR_LIT>" , username , realm ) <EOL> self . assertEqual ( start_count + <NUM_LIT:1> , len ( self . storage_passwords ) ) <EOL> self . assertEqual ( p . realm , realm ) <EOL> self . assertEqual ( p . username , username ) <EOL> self . assertEqual ( p . clear_password , "<STR_LIT>" ) <EOL> self . assertEqual ( p . name , realm + "<STR_LIT::>" + username + "<STR_LIT::>" ) <EOL> p . delete ( ) <EOL> self . assertEqual ( start_count , len ( self . storage_passwords ) ) <EOL> def test_create_norealm ( self ) : <EOL> start_count = len ( self . storage_passwords ) <EOL> username = testlib . tmpname ( ) <EOL> p = self . storage_passwords . create ( "<STR_LIT>" , username ) <EOL> self . assertEqual ( start_count + <NUM_LIT:1> , len ( self . storage_passwords ) ) <EOL> self . assertEqual ( p . realm , None ) <EOL> self . assertEqual ( p . username , username ) <EOL> self . assertEqual ( p . clear_password , "<STR_LIT>" ) <EOL> self . assertEqual ( p . name , "<STR_LIT::>" + username + "<STR_LIT::>" ) <EOL> p . delete ( ) <EOL> self . assertEqual ( start_count , len ( self . storage_passwords ) ) <EOL> def test_create_with_colons ( self ) : <EOL> start_count = len ( self . storage_passwords ) <EOL> username = testlib . tmpname ( ) <EOL> realm = testlib . tmpname ( ) <EOL> p = self . storage_passwords . create ( "<STR_LIT>" , username + "<STR_LIT>" , <EOL> "<STR_LIT>" + realm ) <EOL> self . assertEqual ( start_count + <NUM_LIT:1> , len ( self . storage_passwords ) ) <EOL> self . assertEqual ( p . realm , "<STR_LIT>" + realm ) <EOL> self . assertEqual ( p . username , username + "<STR_LIT>" ) <EOL> self . assertEqual ( p . clear_password , "<STR_LIT>" ) <EOL> self . assertEqual ( p . name , <EOL> "<STR_LIT>" + realm + "<STR_LIT::>" + username + "<STR_LIT>" ) <EOL> p . delete ( ) <EOL> self . assertEqual ( start_count , len ( self . storage_passwords ) ) <EOL> prefix = testlib . tmpname ( ) <EOL> realm = prefix + "<STR_LIT>" <EOL> user = "<STR_LIT>" <EOL> p = self . storage_passwords . create ( "<STR_LIT>" , user , realm ) <EOL> self . assertEqual ( start_count + <NUM_LIT:1> , len ( self . storage_passwords ) ) <EOL> self . assertEqual ( p . realm , realm ) <EOL> self . assertEqual ( p . username , user ) <EOL> self . assertEqual ( p . clear_password , "<STR_LIT>" ) <EOL> self . assertEqual ( p . name , <EOL> prefix + "<STR_LIT>" ) <EOL> p . delete ( ) <EOL> self . assertEqual ( start_count , len ( self . storage_passwords ) ) <EOL> def test_create_crazy ( self ) : <EOL> start_count = len ( self . storage_passwords ) <EOL> username = testlib . tmpname ( ) <EOL> realm = testlib . tmpname ( ) <EOL> p = self . storage_passwords . create ( "<STR_LIT>" , <EOL> username + "<STR_LIT>" , <EOL> "<STR_LIT>" + realm ) <EOL> self . assertEqual ( start_count + <NUM_LIT:1> , len ( self . storage_passwords ) ) <EOL> self . assertEqual ( p . realm , "<STR_LIT>" + realm ) <EOL> self . assertEqual ( p . username , username + "<STR_LIT>" ) <EOL> self . assertEqual ( p . clear_password , "<STR_LIT>" ) <EOL> self . assertEqual ( p . name , <EOL> "<STR_LIT>" + realm + "<STR_LIT::>" + username + "<STR_LIT>" ) <EOL> p . delete ( ) <EOL> self . assertEqual ( start_count , len ( self . storage_passwords ) ) <EOL> def test_read ( self ) : <EOL> start_count = len ( self . storage_passwords ) <EOL> username = testlib . tmpname ( ) <EOL> p = self . storage_passwords . create ( "<STR_LIT>" , username ) <EOL> self . assertEqual ( start_count + <NUM_LIT:1> , len ( self . storage_passwords ) ) <EOL> for sp in self . storage_passwords : <EOL> self . assertTrue ( p . name in self . storage_passwords ) <EOL> self . assertTrue ( ( "<STR_LIT::>" + username + "<STR_LIT::>" ) in self . storage_passwords ) <EOL> self . assertTrue ( ( "<STR_LIT::>" + username ) in self . storage_passwords ) <EOL> p . delete ( ) <EOL> self . assertEqual ( start_count , len ( self . storage_passwords ) ) <EOL> def test_update ( self ) : <EOL> start_count = len ( self . storage_passwords ) <EOL> realm = testlib . tmpname ( ) <EOL> username = testlib . tmpname ( ) <EOL> p = self . storage_passwords . create ( "<STR_LIT>" , username , realm ) <EOL> self . assertEqual ( start_count + <NUM_LIT:1> , len ( self . storage_passwords ) ) <EOL> self . assertEqual ( p . realm , realm ) <EOL> self . assertEqual ( p . username , username ) <EOL> self . assertEqual ( p . clear_password , "<STR_LIT>" ) <EOL> self . assertEqual ( p . name , realm + "<STR_LIT::>" + username + "<STR_LIT::>" ) <EOL> p . update ( password = "<STR_LIT>" ) <EOL> self . assertEqual ( p . clear_password , "<STR_LIT>" ) <EOL> p . refresh ( ) <EOL> self . assertEqual ( start_count + <NUM_LIT:1> , len ( self . storage_passwords ) ) <EOL> self . assertEqual ( p . realm , realm ) <EOL> self . assertEqual ( p . username , username ) <EOL> self . assertEqual ( p . clear_password , "<STR_LIT>" ) <EOL> self . assertEqual ( p . name , realm + "<STR_LIT::>" + username + "<STR_LIT::>" ) <EOL> p . delete ( ) <EOL> self . assertEqual ( start_count , len ( self . storage_passwords ) ) <EOL> def test_delete ( self ) : <EOL> start_count = len ( self . storage_passwords ) <EOL> username = testlib . tmpname ( ) <EOL> p = self . storage_passwords . create ( "<STR_LIT>" , username , "<STR_LIT>" ) <EOL> self . assertEqual ( start_count + <NUM_LIT:1> , len ( self . storage_passwords ) ) <EOL> self . assertEqual ( p . realm , "<STR_LIT>" ) <EOL> self . assertEqual ( p . username , username ) <EOL> self . assertEqual ( p . clear_password , "<STR_LIT>" ) <EOL> self . assertEqual ( p . name , "<STR_LIT>" + username + "<STR_LIT::>" ) <EOL> self . storage_passwords . delete ( username , "<STR_LIT>" ) <EOL> self . assertEqual ( start_count , len ( self . storage_passwords ) ) <EOL> self . storage_passwords . create ( "<STR_LIT>" , username , "<STR_LIT>" ) <EOL> self . assertEqual ( start_count + <NUM_LIT:1> , len ( self . storage_passwords ) ) <EOL> self . storage_passwords . delete ( "<STR_LIT>" + username + "<STR_LIT::>" ) <EOL> self . assertEqual ( start_count , len ( self . storage_passwords ) ) <EOL> self . storage_passwords . create ( password = "<STR_LIT>" , username = username , <EOL> realm = "<STR_LIT>" ) <EOL> self . assertEqual ( start_count + <NUM_LIT:1> , len ( self . storage_passwords ) ) <EOL> self . storage_passwords . delete ( username , "<STR_LIT>" ) <EOL> self . assertEqual ( start_count , len ( self . storage_passwords ) ) <EOL> self . storage_passwords . create ( password = "<STR_LIT>" , username = username + "<STR_LIT>" , <EOL> realm = "<STR_LIT>" ) <EOL> self . assertEqual ( start_count + <NUM_LIT:1> , len ( self . storage_passwords ) ) <EOL> self . storage_passwords . delete ( username + "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . assertEqual ( start_count , len ( self . storage_passwords ) ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> try : <EOL> import unittest2 as unittest <EOL> except ImportError : <EOL> import unittest <EOL> unittest . main ( ) </s>
