Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom client + parse macro + signature check functions #44

Merged
merged 28 commits into from
Aug 9, 2021
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8d8137b
attempt at custom client
JakubKoralewski Jul 7, 2021
26399df
add parse macro and tests
JakubKoralewski Jul 9, 2021
1e4820f
allow passing a client builder
JakubKoralewski Jul 11, 2021
3808b07
small fixes
JakubKoralewski Jul 14, 2021
51dde3d
make `fn encode` public
JakubKoralewski Jul 14, 2021
3424142
Merge pull request #1 from JakubKoralewski/custom-client-w-builder
JakubKoralewski Jul 14, 2021
82d6e96
add docs and fix formtting
JakubKoralewski Jul 15, 2021
838f53d
encode return Cow<str> instead of String
JakubKoralewski Jul 15, 2021
5b2423f
add check signature functions w/ tests
JakubKoralewski Jul 15, 2021
9487db2
Merge pull request #2 from JakubKoralewski/signature-check
JakubKoralewski Jul 15, 2021
d779914
update examples
JakubKoralewski Jul 15, 2021
dad3695
fix: dont re-encode while checking cus it's already encoded
JakubKoralewski Jul 15, 2021
d81bced
fix Cargo.toml formatting
JakubKoralewski Jul 19, 2021
49f18b0
run `cargo fmt`
JakubKoralewski Jul 19, 2021
cac4479
naming conventions
JakubKoralewski Jul 19, 2021
ef280bb
remove calls to `dbg!`
JakubKoralewski Jul 19, 2021
a657a04
fix: warnings and cfg-miscompilations
JakubKoralewski Jul 19, 2021
6c8b0a8
docs: add `check_signature_request` example
JakubKoralewski Jul 19, 2021
37ddcda
docs: make `count!` `#[doc(hidden)]`
JakubKoralewski Jul 19, 2021
4e10c44
docs: add async example
JakubKoralewski Jul 19, 2021
5758fe3
Make `Error` type generic over RequestBuildah types
gifnksm Aug 9, 2021
581b8a6
Enable `reqwest/blocing` only if `reqwest-blocing` feature is enabled
gifnksm Aug 9, 2021
3a35b91
Fix typo
gifnksm Aug 9, 2021
f25d7a2
Renable `RequestBuildah` to `RequestBuilder`
gifnksm Aug 9, 2021
69ba568
Make `parse_query_string` a function
gifnksm Aug 9, 2021
5c07822
Remove count macro
gifnksm Aug 9, 2021
e772c84
update `parse_query_string` docs
JakubKoralewski Aug 9, 2021
eadccb0
update names of test cases
JakubKoralewski Aug 9, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/target
/Cargo.lock
.history
.idea
11 changes: 11 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,21 @@ ring = "0.16.20"
time = "0.2.26"
percent-encoding = "2.1.0"
thiserror = "1.0.24"
http="0.2"
url="2"

[features]
client-reqwest=["reqwest"]
reqwest-blocking=["client-reqwest"]
default=["client-reqwest", "reqwest-blocking"]

[dependencies.reqwest]
optional=true
version = "0.11.3"
features = ["blocking"]
gifnksm marked this conversation as resolved.
Show resolved Hide resolved

[dev-dependencies]
simple_logger="1"

JakubKoralewski marked this conversation as resolved.
Show resolved Hide resolved
[badges]
maintenance = { status = "passively-maintained" }
17 changes: 10 additions & 7 deletions examples/test_get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
unused_results
)]

use oauth_client::{self as oauth, Token};
use oauth_client::{self as oauth, Token, DefaultRequestBuilder};
use rand::{distributions::Alphanumeric, Rng};
use std::borrow::Cow;
use std::collections::HashMap;
Expand All @@ -38,8 +38,9 @@ fn split_query(query: &'_ str) -> HashMap<Cow<'_, str>, Cow<'_, str>> {
}

fn get_request_token(consumer: &Token<'_>) -> Token<'static> {
let bytes = oauth::get(api::REQUEST_TOKEN, consumer, None, None).unwrap();
let resp = String::from_utf8(bytes).unwrap();
let resp = oauth::get::<DefaultRequestBuilder>(
api::REQUEST_TOKEN, consumer, None, None, &()
).unwrap();
println!("get_request_token response: {:?}", resp);
let param = split_query(&resp);
Token::new(
Expand All @@ -49,8 +50,9 @@ fn get_request_token(consumer: &Token<'_>) -> Token<'static> {
}

fn get_access_token(consumer: &Token<'_>, request: &Token<'_>) -> Token<'static> {
let bytes = oauth::get(api::ACCESS_TOKEN, consumer, Some(request), None).unwrap();
let resp = String::from_utf8(bytes).unwrap();
let resp = oauth::get::<DefaultRequestBuilder>(
api::ACCESS_TOKEN, consumer, Some(request), None, &()
).unwrap();
println!("get_access_token response: {:?}", resp);
let param = split_query(&resp);
Token::new(
Expand All @@ -77,8 +79,9 @@ fn echo(consumer: &Token<'_>, access: &Token<'_>) {
.collect(),
);
}
let bytes = oauth::get(api::ECHO, consumer, Some(access), Some(&req_param)).unwrap();
let resp = String::from_utf8(bytes).unwrap();
let resp = oauth::get::<DefaultRequestBuilder>(
api::ECHO, consumer, Some(access), Some(&req_param), &()
).unwrap();
println!("echo response: {:?}", resp);
let resp_param = split_query(&resp);
assert_eq!(req_param, resp_param);
Expand Down
17 changes: 10 additions & 7 deletions examples/test_post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
unused_results
)]

use oauth_client::{self as oauth, Token};
use oauth_client::{self as oauth, Token, DefaultRequestBuilder};
use rand::{distributions::Alphanumeric, Rng};
use std::borrow::Cow;
use std::collections::HashMap;
Expand All @@ -38,8 +38,9 @@ fn split_query(query: &'_ str) -> HashMap<Cow<'_, str>, Cow<'_, str>> {
}

fn get_request_token(consumer: &Token<'_>) -> Token<'static> {
let bytes = oauth::post(api::REQUEST_TOKEN, consumer, None, None).unwrap();
let resp = String::from_utf8(bytes).unwrap();
let resp = oauth::post::<DefaultRequestBuilder>(
api::REQUEST_TOKEN, consumer, None, None, &()
).unwrap();
println!("get_request_token response: {:?}", resp);
let param = split_query(&resp[..]);
Token::new(
Expand All @@ -49,8 +50,9 @@ fn get_request_token(consumer: &Token<'_>) -> Token<'static> {
}

fn get_access_token(consumer: &Token<'_>, request: &Token<'_>) -> Token<'static> {
let bytes = oauth::post(api::ACCESS_TOKEN, consumer, Some(request), None).unwrap();
let resp = String::from_utf8(bytes).unwrap();
let resp = oauth::post::<DefaultRequestBuilder>(
api::ACCESS_TOKEN, consumer, Some(request), None, &()
).unwrap();
println!("get_access_token response: {:?}", resp);
let param = split_query(&resp[..]);
Token::new(
Expand All @@ -77,8 +79,9 @@ fn echo(consumer: &Token<'_>, access: &Token<'_>) {
.collect(),
);
}
let bytes = oauth::post(api::ECHO, consumer, Some(access), Some(&req_param)).unwrap();
let resp = String::from_utf8(bytes).unwrap();
let resp = oauth::post::<DefaultRequestBuilder>(
api::ECHO, consumer, Some(access), Some(&req_param), &()
).unwrap();
println!("echo response: {:?}", resp);
let resp_param = split_query(&resp[..]);
assert_eq!(req_param, resp_param);
Expand Down
Loading