summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorD. Scott Boggs <scott@tams.tech>2023-09-28 08:31:11 -0400
committerD. Scott Boggs <scott@tams.tech>2023-09-28 08:41:52 -0400
commita9a7ce253069458385fc4b01e626932bc8fca777 (patch)
tree4fe742804255fae7df8488e4ab0231ad6651a2dd
parent76ba2dd479b24ca1cf077927031cbc86c6e167e7 (diff)
finish migration to strict OAuthToken typecomb-methods/oauth-2
-rw-r--r--src/data.rs8
-rw-r--r--src/helpers/env.rs4
-rw-r--r--src/helpers/json.rs18
-rw-r--r--src/helpers/toml.rs18
-rw-r--r--src/mastodon.rs2
5 files changed, 25 insertions, 25 deletions
diff --git a/src/data.rs b/src/data.rs
index 0dd8cd0..1c53ce8 100644
--- a/src/data.rs
+++ b/src/data.rs
@@ -1,5 +1,5 @@
use derive_builder::Builder;
-use mastodon_async_entities::{ClientId, ClientSecret};
+use mastodon_async_entities::{ClientId, ClientSecret, OAuthToken};
use serde::{Deserialize, Serialize};
/// Raw data about mastodon app. Save `Data` using `serde` to prevent needing
@@ -25,7 +25,7 @@ pub struct Data {
pub redirect: String,
#[builder(private, setter(into))]
/// The client's access token.
- pub token: String,
+ pub token: OAuthToken,
}
impl Data {
@@ -34,7 +34,7 @@ impl Data {
base: impl Into<String>,
client_id: ClientId,
client_secret: ClientSecret,
- token: impl Into<String>,
+ token: OAuthToken,
) -> DataBuilder {
let mut builder = DataBuilder::create_empty();
builder
@@ -62,7 +62,7 @@ impl Default for Data {
client_secret: String::default().into(),
base: String::default(),
redirect: String::default(),
- token: String::default(),
+ token: String::default().into(),
}
}
}
diff --git a/src/helpers/env.rs b/src/helpers/env.rs
index 5dc7749..c16841c 100644
--- a/src/helpers/env.rs
+++ b/src/helpers/env.rs
@@ -58,7 +58,7 @@ mod tests {
client_id: String::from("adbc01234").into(),
client_secret: String::from("0987dcba").into(),
redirect: "urn:ietf:wg:oauth:2.0:oob".into(),
- token: "fedc5678".into(),
+ token: String::from("fedc5678").into(),
}
);
}
@@ -73,7 +73,7 @@ mod tests {
client_id: String::from("adbc01234").into(),
client_secret: String::from("0987dcba").into(),
redirect: "urn:ietf:wg:oauth:2.0:oob".into(),
- token: "fedc5678".into(),
+ token: String::from("fedc5678").into(),
}
);
}
diff --git a/src/helpers/json.rs b/src/helpers/json.rs
index 752ba7c..a6bed6d 100644
--- a/src/helpers/json.rs
+++ b/src/helpers/json.rs
@@ -101,7 +101,7 @@ mod tests {
client_id: String::from("adbc01234").into(),
client_secret: String::from("0987dcba").into(),
redirect: "urn:ietf:wg:oauth:2.0:oob".into(),
- token: "fedc5678".into(),
+ token: String::from("fedc5678").into(),
}
);
}
@@ -116,7 +116,7 @@ mod tests {
client_id: String::from("adbc01234").into(),
client_secret: String::from("0987dcba").into(),
redirect: "urn:ietf:wg:oauth:2.0:oob".into(),
- token: "fedc5678".into(),
+ token: String::from("fedc5678").into(),
}
);
}
@@ -132,7 +132,7 @@ mod tests {
client_id: String::from("adbc01234").into(),
client_secret: String::from("0987dcba").into(),
redirect: "urn:ietf:wg:oauth:2.0:oob".into(),
- token: "fedc5678".into(),
+ token: String::from("fedc5678").into(),
}
);
}
@@ -148,7 +148,7 @@ mod tests {
client_id: String::from("adbc01234").into(),
client_secret: String::from("0987dcba").into(),
redirect: "urn:ietf:wg:oauth:2.0:oob".into(),
- token: "fedc5678".into(),
+ token: String::from("fedc5678").into(),
}
);
}
@@ -159,7 +159,7 @@ mod tests {
client_id: String::from("adbc01234").into(),
client_secret: String::from("0987dcba").into(),
redirect: "urn:ietf:wg:oauth:2.0:oob".into(),
- token: "fedc5678".into(),
+ token: String::from("fedc5678").into(),
};
let s = to_string(&data).expect("Couldn't serialize Data");
let desered = from_str(&s).expect("Couldn't deserialize Data");
@@ -172,7 +172,7 @@ mod tests {
client_id: String::from("adbc01234").into(),
client_secret: String::from("0987dcba").into(),
redirect: "urn:ietf:wg:oauth:2.0:oob".into(),
- token: "fedc5678".into(),
+ token: String::from("fedc5678").into(),
};
let v = to_vec(&data).expect("Couldn't write to vec");
let desered = from_slice(&v).expect("Couldn't deserialize data");
@@ -185,7 +185,7 @@ mod tests {
client_id: String::from("adbc01234").into(),
client_secret: String::from("0987dcba").into(),
redirect: "urn:ietf:wg:oauth:2.0:oob".into(),
- token: "fedc5678".into(),
+ token: String::from("fedc5678").into(),
};
let mut buffer = Vec::new();
to_writer(&data, &mut buffer).expect("Couldn't write to writer");
@@ -200,7 +200,7 @@ mod tests {
client_id: String::from("adbc01234").into(),
client_secret: String::from("0987dcba").into(),
redirect: "urn:ietf:wg:oauth:2.0:oob".into(),
- token: "fedc5678".into(),
+ token: String::from("fedc5678").into(),
};
let tempdir = tempdir().expect("Couldn't create tempdir");
let filename = tempdir.path().join("mastodon-data.json");
@@ -215,7 +215,7 @@ mod tests {
client_id: String::from("adbc01234").into(),
client_secret: String::from("0987dcba").into(),
redirect: "urn:ietf:wg:oauth:2.0:oob".into(),
- token: "fedc5678".into(),
+ token: String::from("fedc5678").into(),
};
let file = NamedTempFile::new().expect("Couldn't create tempfile");
let mut options = OpenOptions::new();
diff --git a/src/helpers/toml.rs b/src/helpers/toml.rs
index 0c77a26..e73b077 100644
--- a/src/helpers/toml.rs
+++ b/src/helpers/toml.rs
@@ -99,7 +99,7 @@ mod tests {
client_id: String::from("adbc01234").into(),
client_secret: String::from("0987dcba").into(),
redirect: "urn:ietf:wg:oauth:2.0:oob".into(),
- token: "fedc5678".into(),
+ token: String::from("fedc5678").into(),
}
);
}
@@ -114,7 +114,7 @@ mod tests {
client_id: String::from("adbc01234").into(),
client_secret: String::from("0987dcba").into(),
redirect: "urn:ietf:wg:oauth:2.0:oob".into(),
- token: "fedc5678".into(),
+ token: String::from("fedc5678").into(),
}
);
}
@@ -130,7 +130,7 @@ mod tests {
client_id: String::from("adbc01234").into(),
client_secret: String::from("0987dcba").into(),
redirect: "urn:ietf:wg:oauth:2.0:oob".into(),
- token: "fedc5678".into(),
+ token: String::from("fedc5678").into(),
}
);
}
@@ -146,7 +146,7 @@ mod tests {
client_id: String::from("adbc01234").into(),
client_secret: String::from("0987dcba").into(),
redirect: "urn:ietf:wg:oauth:2.0:oob".into(),
- token: "fedc5678".into(),
+ token: String::from("fedc5678").into(),
}
);
}
@@ -157,7 +157,7 @@ mod tests {
client_id: String::from("adbc01234").into(),
client_secret: String::from("0987dcba").into(),
redirect: "urn:ietf:wg:oauth:2.0:oob".into(),
- token: "fedc5678".into(),
+ token: String::from("fedc5678").into(),
};
let s = to_string(&data).expect("Couldn't serialize Data");
let desered = from_str(&s).expect("Couldn't deserialize Data");
@@ -170,7 +170,7 @@ mod tests {
client_id: String::from("adbc01234").into(),
client_secret: String::from("0987dcba").into(),
redirect: "urn:ietf:wg:oauth:2.0:oob".into(),
- token: "fedc5678".into(),
+ token: String::from("fedc5678").into(),
};
let v = to_vec(&data).expect("Couldn't write to vec");
let desered = from_slice(&v).expect("Couldn't deserialize data");
@@ -183,7 +183,7 @@ mod tests {
client_id: String::from("adbc01234").into(),
client_secret: String::from("0987dcba").into(),
redirect: "urn:ietf:wg:oauth:2.0:oob".into(),
- token: "fedc5678".into(),
+ token: String::from("fedc5678").into(),
};
let mut buffer = Vec::new();
to_writer(&data, &mut buffer).expect("Couldn't write to writer");
@@ -198,7 +198,7 @@ mod tests {
client_id: String::from("adbc01234").into(),
client_secret: String::from("0987dcba").into(),
redirect: "urn:ietf:wg:oauth:2.0:oob".into(),
- token: "fedc5678".into(),
+ token: String::from("fedc5678").into(),
};
let tempdir = tempdir().expect("Couldn't create tempdir");
let filename = tempdir.path().join("mastodon-data.toml");
@@ -213,7 +213,7 @@ mod tests {
client_id: String::from("adbc01234").into(),
client_secret: String::from("0987dcba").into(),
redirect: "urn:ietf:wg:oauth:2.0:oob".into(),
- token: "fedc5678".into(),
+ token: String::from("fedc5678").into(),
};
let file = NamedTempFile::new().expect("Couldn't create tempfile");
let mut options = OpenOptions::new();
diff --git a/src/mastodon.rs b/src/mastodon.rs
index e28dfe1..1bd82c9 100644
--- a/src/mastodon.rs
+++ b/src/mastodon.rs
@@ -512,7 +512,7 @@ impl MastodonUnauthenticated {
self.base.clone(),
app.client_id,
app.client_secret,
- oauth_token.as_ref(),
+ oauth_token,
)
.build();
Mastodon::new(reqwest::Client::new(), data)