Skip to content

Commit

Permalink
removed async from MqttTokenFetcher
Browse files Browse the repository at this point in the history
  • Loading branch information
isik508 committed Aug 26, 2024
1 parent 315a8bf commit dfe3c80
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 0 additions & 1 deletion dsh_sdk/examples/mqtt_token_fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ async fn main() {
let api_key = env::var("API_KEY").unwrap().to_string();
let mqtt_token_fetcher: MqttTokenFetcher =
MqttTokenFetcher::new(tenant_name, api_key, None, dsh_sdk::Platform::NpLz) //Claims = None fetches all possible claims
.await
.unwrap();
let token: MqttToken = mqtt_token_fetcher
.get_token("Client-id", None)
Expand Down
1 change: 0 additions & 1 deletion dsh_sdk/examples/mqtt_token_fetcher_specific_claims.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ async fn main() {
Some(claims_vector),
dsh_sdk::Platform::NpLz,
)
.await
.unwrap();

let token: MqttToken = mqtt_token_fetcher
Expand Down
13 changes: 11 additions & 2 deletions dsh_sdk/src/mqtt_token_fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ pub struct MqttTokenFetcher {
}

impl MqttTokenFetcher {
pub async fn new(
pub fn new(
tenant_name: String,
rest_api_key: String,
claims: Option<Vec<Claims>>,
platform: Platform,
//token_lifetime: Option<i32>,
) -> Result<MqttTokenFetcher, DshError> {
let rest_token = RestToken::get(&tenant_name, &rest_api_key, &platform).await?;
let rest_token = RestToken::default();
Ok(Self {
tenant_name: tenant_name.clone(),
rest_api_key: rest_api_key.clone(),
Expand Down Expand Up @@ -330,6 +330,15 @@ impl RestToken {
}

Check warning on line 330 in dsh_sdk/src/mqtt_token_fetcher.rs

View check run for this annotation

Codecov / codecov/patch

dsh_sdk/src/mqtt_token_fetcher.rs#L330

Added line #L330 was not covered by tests
}

impl Default for RestToken {
fn default() -> Self {
Self {
raw_token: "".to_string(),
exp: 0,
}
}

Check warning on line 339 in dsh_sdk/src/mqtt_token_fetcher.rs

View check run for this annotation

Codecov / codecov/patch

dsh_sdk/src/mqtt_token_fetcher.rs#L334-L339

Added lines #L334 - L339 were not covered by tests
}

fn extract_header_and_payload(raw_token: &str) -> Result<&str, DshError> {
let parts: Vec<&str> = raw_token.split('.').collect();
parts
Expand Down

0 comments on commit dfe3c80

Please sign in to comment.