Skip to content

Commit

Permalink
ci: setup test ci
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelgautier committed Mar 11, 2024
1 parent 358d7f3 commit 3612d5d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "Test Suite"
on:
push:
pull_request:

jobs:
test:
name: cargo test

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- run: cargo test --all-features

formatting:
name: cargo fmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt

- name: Rustfmt Check
uses: actions-rust-lang/rustfmt@v1
13 changes: 10 additions & 3 deletions baffao-core/src/oauth/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ use std::time::Duration;

use anyhow::Context;
use oauth2::{
basic::{BasicClient, BasicTokenType}, reqwest::async_http_client, AccessToken, AuthType, AuthUrl, AuthorizationCode, ClientId, ClientSecret, CsrfToken, RedirectUrl, RefreshToken, Scope, StandardErrorResponse, TokenResponse, TokenUrl
basic::BasicClient, reqwest::async_http_client, AccessToken, AuthType, AuthUrl,
AuthorizationCode, ClientId, ClientSecret, CsrfToken, RedirectUrl, RefreshToken, Scope,
TokenResponse, TokenUrl,
};
use reqwest::Url;

Expand Down Expand Up @@ -58,12 +60,17 @@ impl OAuthClient {
}

let code = AuthorizationCode::new(code);
let token = self.client
let token = self
.client
.exchange_code(code)
.request_async(async_http_client)
.await
.context("Failed to exchange code")?;

Ok((token.access_token().clone(), token.refresh_token().cloned(), token.expires_in()))
Ok((
token.access_token().clone(),
token.refresh_token().cloned(),
token.expires_in(),
))
}
}

0 comments on commit 3612d5d

Please sign in to comment.