Skip to content

Commit

Permalink
py: Optionalize Credentials on pairing
Browse files Browse the repository at this point in the history
Default to Nobody credentials if none are given, this is a convenient
way for developers to initialize a pairing session and in line which how
the scheduler api behaves.

Signed-off-by: Peter Neuroth <[email protected]>
  • Loading branch information
nepet committed Oct 1, 2024
1 parent ac50cd2 commit d356f35
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions libs/gl-client-py/glclient/pairing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
class NewDeviceClient(object):
"""A Pairing Client for the "new device" flow."""

def __init__(self, creds: Credentials, uri: Optional[str] = None):
self._inner = native.NewDeviceClient(creds=creds, uri=uri)
def __init__(self, creds: Optional[Credentials] = None, uri: Optional[str] = None):
self.creds = creds if creds is not None else Credentials()
self._inner = native.NewDeviceClient(creds=self.creds, uri=uri)

def _recv(self, m):
msgs = {
Expand Down
3 changes: 2 additions & 1 deletion libs/gl-client-py/tests/test_pairing.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_pairing_session(sclient, signer, creds):
name = "new_device"
desc = "my_description"
restrs = "method^list"
ps = NewDeviceClient(creds)
ps = NewDeviceClient()
session = ps.pair_device(name, desc, restrs)
session_iter = iter(session)

Expand All @@ -33,6 +33,7 @@ def test_pairing_session(sclient, signer, creds):
scheduler.schedule()

# check for pairing data.
assert isinstance(m, str)
device_id = m.split(':')[1]
ac = AttestationDeviceClient(creds=creds)
m = ac.get_pairing_data(device_id)
Expand Down

0 comments on commit d356f35

Please sign in to comment.