Skip to content

Commit

Permalink
pairing: Replace TlsConfig
Browse files Browse the repository at this point in the history
This commit replaces TlsConfig dependencies introduced by the
signerless device pairing with Credentials.

Signed-off-by: Peter Neuroth <[email protected]>
  • Loading branch information
nepet committed Jun 2, 2024
1 parent 75f35e4 commit eefc7d3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
4 changes: 2 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,8 @@
class NewDeviceClient(object):
"""A Pairing Client for the "new device" flow."""

def __init__(self, tls: TlsConfig, uri: Optional[str] = None):
self._inner = native.NewDeviceClient(tls=tls.inner, uri=uri)
def __init__(self, creds: Credentials, uri: Optional[str] = None):
self._inner = native.NewDeviceClient(creds=creds, uri=uri)

def _recv(self, m):
msgs = {
Expand Down
5 changes: 2 additions & 3 deletions libs/gl-client-py/src/pairing.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::credentials::Credentials;
use crate::runtime::exec;
use crate::tls::TlsConfig;
use bytes::BufMut;
use gl_client::pairing::{attestation_device, new_device, PairingSessionData};
use gl_client::pb::scheduler::GetPairingDataResponse;
Expand All @@ -17,8 +16,8 @@ pub struct NewDeviceClient {
#[pymethods]
impl NewDeviceClient {
#[new]
fn new(tls: TlsConfig, uri: Option<String>) -> Result<Self> {
let mut client = new_device::Client::new(tls.inner);
fn new(creds: Credentials, uri: Option<String>) -> Result<Self> {
let mut client = new_device::Client::new(creds.inner);

if let Some(uri) = uri {
client = client.with_uri(uri);
Expand Down
4 changes: 2 additions & 2 deletions libs/gl-client-py/tests/test_pairing.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_pairing_session(sclient, signer, creds):
name = "new_device"
desc = "my_description"
restrs = "method^list"
ps = NewDeviceClient(TlsConfig(creds))
ps = NewDeviceClient(creds)
session = ps.pair_device(name, desc, restrs)
session_iter = iter(session)

Expand Down Expand Up @@ -72,7 +72,7 @@ def test_paring_data_validation(attestation_device, creds):
desc = "my description"
restrs = "method^list"

dc = NewDeviceClient(TlsConfig(creds))
dc = NewDeviceClient(creds)
session = dc.pair_device(name, desc, restrs)
session_iter = iter(session)
m = next(session_iter)
Expand Down
9 changes: 6 additions & 3 deletions libs/gl-client/src/pairing/new_device.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::PairingSessionData;
use crate::{
credentials::Device,
credentials::{Device, TlsConfigProvider},
pb::scheduler::{pairing_client::PairingClient, PairDeviceRequest, PairingQr},
tls::{self, TlsConfig},
};
Expand All @@ -20,11 +20,14 @@ pub struct Client<T> {
}

impl Client<Unconnected> {
pub fn new(tls: TlsConfig) -> Client<Unconnected> {
pub fn new<T>(creds: T) -> Client<Unconnected>
where
T: TlsConfigProvider,
{
Client {
inner: Unconnected(),
uri: crate::utils::scheduler_uri(),
tls,
tls: creds.tls_config(),
}
}
}
Expand Down

0 comments on commit eefc7d3

Please sign in to comment.