Guest User

Untitled

a guest
Aug 31st, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.19 KB | None | 0 0
  1. import paramiko
  2. import SSH
  3. import unittest
  4. from test import support
  5.  
  6. class SwitchAccount(unittest.TestCase):
  7.  
  8.  
  9.  
  10. def setUp(self):
  11.  
  12. self.s = testcore.control.ssh.SSH(host='xxx.xx.xx.xxx', username='admin', password='admin')
  13. if self.s.login():
  14.  
  15. print('connection succesfull')
  16. else:
  17. print('connection negativ')
  18.  
  19.  
  20. self.s.query_interactive = True
  21.  
  22.  
  23.  
  24. def test_change_Enforce_Enable(self):
  25.  
  26. if self.s.login():
  27. q = self.s.query('account')
  28.  
  29. # switch to prompt account
  30.  
  31. q = self.s.query('enforce-Password-Rules yes')
  32.  
  33.  
  34. def test_create_user_rights_1(self):
  35.  
  36. if self.s.login():
  37. q = self.s.query('account')
  38.  
  39. # switch to prompt account
  40.  
  41. q = self.s.query('add 1 testuser_P1 testuser_P1')
  42. q = self.s.query('logout')
  43.  
  44. def setUp(self):
  45. self.s = testcore.control.ssh.SSH(host='xxx.xx.xx.xxx', username='testuser_P1', password='testuser_P1')
  46.  
  47. if self.s.login():
  48.  
  49. print('connection succesfull')
  50. else:
  51. print('connection negativ')
  52. import time
  53. print('Wait')
  54. time.sleep(6)
  55.  
  56.  
  57. def test_try_wrong_promp_command(self):
  58.  
  59. if self.s.login():
  60. q = self.s.query('account')
  61.  
  62. # switch to prompt account
  63.  
  64. q = self.s.query('aaa')
  65. q = self.s.query('trace ')
  66. import time
  67. print('Wait')
  68. time.sleep(6)
  69.  
  70.  
  71. def test_create_user_rights_2(self):
  72.  
  73. if self.s.login():
  74. q = self.s.query('account')
  75.  
  76. # switch to prompt account
  77.  
  78. q = self.s.query('add 2 testuser_P2 testuser_P2')
  79. import time
  80. print('Wait')
  81. time.sleep(6)
  82.  
  83.  
  84. q = self.s.query('logout')
  85.  
  86. def setUp(self):
  87. self.s = testcore.control.ssh.SSH(host='xxx.xx.xx.xxx', username='testuser_P2', password='testuser_P2')
  88.  
  89. if self.s.login():
  90.  
  91. print('connection succesfull')
  92. else:
  93. print('connection negativ')
  94.  
  95.  
  96. def test_try_wrong_promp_command(self):
  97.  
  98. if self.s.login():
  99. q = self.s.query('account')
  100.  
  101. # switch to prompt account
  102.  
  103. q = self.s.query('aaa')
  104. q = self.s.query('trace ')
  105.  
  106.  
  107.  
  108. if __name__ == '__main__':
  109. unittest.main(verbosity=3)
  110. unittest.main(warnings='ig-nore')
  111. log_file = 'log_file.txt'
  112. f = open(log_file, "w")
  113.  
  114. import Paramiko
  115. import SSH
  116. import unittest
  117. from test import support
  118.  
  119. class SwitchAccount(unittest.TestCase):
  120.  
  121. def setUp(self):
  122.  
  123. self.s = testcore.control.ssh.SSH(host='xxx.xx.xx.xxx', username='admin', password='admin')
  124. if self.s.login():
  125.  
  126. print('connection succesfull')
  127. else:
  128. print('connection negativ')
  129.  
  130.  
  131. self.s.query_interactive = True
  132.  
  133. def test_create_user_rights_1(self):
  134.  
  135. if self.s.login():
  136. q = self.s.query('account')
  137.  
  138. # switch to prompt account
  139.  
  140. q = self.s.query('add 1 testuser_P1 testuser_P1')
  141. q = self.s.query('logout')
  142.  
  143. def setUp(self):
  144. self.s = testcore.control.ssh.SSH(host='xxx.xx.xx.xxx', username='testuser_P1', password='testuser_P1')
  145.  
  146. if self.s.login():
  147.  
  148. print('connection succesfull')
  149. else:
  150. print('connection negativ')
  151. import time
  152. print('Wait')
  153. time.sleep(6)
  154.  
  155.  
  156. def test_try_wrong_promp_command(self):
  157.  
  158. if self.s.login():
  159. q = self.s.query('account')
  160.  
  161. # switch to prompt account
  162.  
  163. q = self.s.query('aaa')
  164. q = self.s.query('trace ')
  165. import time
  166. print('Wait')
  167. time.sleep(6)
  168.  
  169. def test_create_user_rights_2(self):
  170.  
  171. if self.s.login():
  172. q = self.s.query('account')
  173.  
  174. # switch to prompt account
  175.  
  176. q = self.s.query('add 2 testuser_P2 testuser_P2')
  177. import time
  178. print('Wait')
  179. time.sleep(6)
  180.  
  181.  
  182. q = self.s.query('logout')
  183.  
  184. def setUp(self):
  185. self.s = testcore.control.ssh.SSH(host='xxx.xx.xx.xxx', username='testuser_P2', password='testuser_P2')
  186.  
  187. if self.s.login():
  188.  
  189. print('connection succesfull')
  190. else:
  191. print('connection negativ')
  192.  
  193.  
  194. def test_try_wrong_promp_command(self):
  195.  
  196. if self.s.login():
  197. q = self.s.query('account')
  198.  
  199. # switch to prompt account
  200.  
  201. q = self.s.query('aaa')
  202. q = self.s.query('trace ')
Add Comment
Please, Sign In to add comment