File tree 1 file changed +16
-0
lines changed
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change
1
+ import io
2
+ import logging
1
3
import lakers
2
4
import cbor2
3
5
import pytest
4
6
from lakers import CredentialTransfer , EdhocInitiator , EdhocResponder
5
7
8
+ # This needs to be early, thus top-level: Once Lakers objects are created, the
9
+ # log level is fixed.
10
+ LOGSTREAM = io .StringIO ()
11
+ logging .basicConfig (stream = LOGSTREAM , level = 0 , force = True )
12
+
6
13
# values from RFC9529, but CRED_I shortened so that passing by value is possible in a 256 byte message
7
14
CRED_I = bytes .fromhex ("A202617808A101A5010202412B2001215820AC75E9ECE3E50BFC8ED60399889522405C47BF16DF96660A41298CB4307F7EB62258206E5DE611388A4B8A8211334AC7D37ECB52A387D257E6DB3C2A93DF21FF3AFFC8" )
8
15
I = bytes .fromhex ("fb13adeb6518cee5f88417660841142e830a81fe334380a953406a1305e8706b" )
@@ -98,6 +105,15 @@ def test_buffer_error():
98
105
_ = initiator .parse_message_2 (cbor2 .dumps (bytes ([1 ] * 10000 )))
99
106
assert str (err .value ) == "MessageBufferError::SliceTooLong"
100
107
108
+ def test_logging ():
109
+ LOGSTREAM .truncate (0 )
110
+ LOGSTREAM .seek (0 )
111
+
112
+ test_handshake_credential_transfer_by (CredentialTransfer .ByValue , CredentialTransfer .ByValue )
113
+
114
+ # So far we don't test much, but that is currently in it an shows that log messages get through.
115
+ assert 'Initializing EdhocInitiator' in LOGSTREAM .getvalue ()
116
+
101
117
@pytest .mark .parametrize ("cred_r_transfer" , [CredentialTransfer .ByReference , CredentialTransfer .ByValue ])
102
118
@pytest .mark .parametrize ("cred_i_transfer" , [CredentialTransfer .ByReference , CredentialTransfer .ByValue ])
103
119
def test_handshake_credential_transfer_by (cred_r_transfer , cred_i_transfer ):
You can’t perform that action at this time.
0 commit comments