55
66import pytest
77
8- from pyipmi .errors import IpmiTimeoutError , IpmiConnectionError , IpmiLongPasswordError
8+ from pyipmi .errors import IpmiTimeoutError , IpmiConnectionError , IpmiLongPasswordError , AuthenticationError
99from pyipmi .interfaces import Ipmitool
1010from pyipmi import Session , Target
1111from pyipmi .utils import py3_array_tobytes
@@ -53,7 +53,7 @@ def test_rmcp_ping(self):
5353
5454 self ._interface .rmcp_ping ()
5555 mock .assert_called_once_with ('ipmitool -I lan -H 10.0.1.1 -p 623 '
56- '-U "admin" -P "secret" '
56+ '-v - U "admin" -P "secret" '
5757 'session info all' )
5858
5959 def test_send_and_receive_raw_valid (self ):
@@ -65,7 +65,7 @@ def test_send_and_receive_raw_valid(self):
6565 self ._interface .send_and_receive_raw (target , 0 , 0x6 , b'\x01 ' )
6666
6767 mock .assert_called_once_with ('ipmitool -I lan -H 10.0.1.1 -p 623 '
68- '-L ADMINISTRATOR -U "admin" -P "secret" '
68+ '-v - L ADMINISTRATOR -U "admin" -P "secret" '
6969 '-t 0x20 -l 0 raw 0x06 0x01 2>&1' )
7070
7171 def test_send_and_receive_raw_lanplus (self ):
@@ -80,7 +80,7 @@ def test_send_and_receive_raw_lanplus(self):
8080 interface .send_and_receive_raw (target , 0 , 0x6 , b'\x01 ' )
8181
8282 mock .assert_called_once_with ('ipmitool -I lanplus -H 10.0.1.1 -p 623 '
83- '-L ADMINISTRATOR -U "admin" -P "secret" '
83+ '-v - L ADMINISTRATOR -U "admin" -P "secret" '
8484 '-t 0x20 -l 0 raw 0x06 0x01 2>&1' )
8585
8686 def test_send_and_receive_raw_cipher (self ):
@@ -95,7 +95,7 @@ def test_send_and_receive_raw_cipher(self):
9595 interface .send_and_receive_raw (target , 0 , 0x6 , b'\x01 ' )
9696
9797 mock .assert_called_once_with ('ipmitool -I lan -H 10.0.1.1 -p 623 '
98- '-L ADMINISTRATOR -C 7 '
98+ '-v - L ADMINISTRATOR -C 7 '
9999 '-U "admin" -P "secret" '
100100 '-t 0x20 -l 0 raw 0x06 0x01 2>&1' )
101101
@@ -110,7 +110,7 @@ def test_send_and_receive_raw_no_auth(self):
110110 self ._interface .send_and_receive_raw (target , 0 , 0x6 , b'\x01 ' )
111111
112112 mock .assert_called_once_with ('ipmitool -I lan -H 10.0.1.1 -p 623 '
113- '-L ADMINISTRATOR -P "" '
113+ '-v - L ADMINISTRATOR -P "" '
114114 '-t 0x20 -l 0 raw 0x06 0x01 2>&1' )
115115
116116 def test_send_and_receive_raw_return_value (self ):
@@ -236,3 +236,9 @@ def test_parse_long_password_error(self):
236236 with pytest .raises (IpmiLongPasswordError ):
237237 cc , rsp = self ._interface ._parse_output (test_str )
238238 assert rsp is None
239+
240+ def test_parse_output_authentication_error (self ):
241+ test_str = b'Loading ...\n Using ...\n > RAKP 2 HMAC is invalid\n Error:'
242+ with pytest .raises (AuthenticationError ):
243+ cc , rsp = self ._interface ._parse_output (test_str )
244+ assert rsp is None
0 commit comments