Skip to content

Commit d94c11e

Browse files
authored
Rename BearerTokenCredentialPolicy -> BearerTokenAuthorizationPolicy (#3256)
1 parent 3842bdc commit d94c11e

File tree

21 files changed

+46
-45
lines changed

21 files changed

+46
-45
lines changed

sdk/core/azure_core/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- Removed `ErrorKind::MockFramework`.
2121
- Removed `Poller::wait()` function. Call `await` on a `Poller` to wait for it to complete and, upon success, return the final model.
2222
- Removed `xml::read_xml_str()`.
23+
- Renamed `BearerTokenCredentialPolicy` to `BearerTokenAuthorizationPolicy`.
2324
- Renamed `xml::read_xml()` to `xml::from_xml()` congruent with `json::from_json()`.
2425

2526
### Bugs Fixed

sdk/core/azure_core/src/http/policies/bearer_token_policy.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ use typespec_client_core::time::{Duration, OffsetDateTime};
1717

1818
/// Authentication policy for a bearer token.
1919
#[derive(Debug, Clone)]
20-
pub struct BearerTokenCredentialPolicy {
20+
pub struct BearerTokenAuthorizationPolicy {
2121
credential: Arc<dyn TokenCredential>,
2222
scopes: Vec<String>,
2323
access_token: Arc<RwLock<Option<AccessToken>>>,
2424
}
2525

26-
impl BearerTokenCredentialPolicy {
27-
/// Creates a new `BearerTokenCredentialPolicy`.
26+
impl BearerTokenAuthorizationPolicy {
27+
/// Creates a new `BearerTokenAuthorizationPolicy`.
2828
pub fn new<A, B>(credential: Arc<dyn TokenCredential>, scopes: A) -> Self
2929
where
3030
A: IntoIterator<Item = B>,
@@ -52,7 +52,7 @@ impl BearerTokenCredentialPolicy {
5252

5353
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
5454
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
55-
impl Policy for BearerTokenCredentialPolicy {
55+
impl Policy for BearerTokenAuthorizationPolicy {
5656
async fn send(
5757
&self,
5858
ctx: &Context,
@@ -209,7 +209,7 @@ mod tests {
209209
async fn authn_error() {
210210
// this mock's get_token() will return an error because it has no tokens
211211
let credential = MockCredential::new(&[]);
212-
let policy = BearerTokenCredentialPolicy::new(Arc::new(credential), ["scope"]);
212+
let policy = BearerTokenAuthorizationPolicy::new(Arc::new(credential), ["scope"]);
213213
let client = MockHttpClient::new(|_| panic!("expected an error from get_token"));
214214
let transport = Arc::new(TransportPolicy::new(Transport::new(Arc::new(client))));
215215
let mut req = Request::new("https://localhost".parse().unwrap(), Method::Get);
@@ -228,7 +228,7 @@ mod tests {
228228

229229
async fn run_test(tokens: &[AccessToken]) {
230230
let credential = Arc::new(MockCredential::new(tokens));
231-
let policy = BearerTokenCredentialPolicy::new(credential.clone(), ["scope"]);
231+
let policy = BearerTokenAuthorizationPolicy::new(credential.clone(), ["scope"]);
232232
let client = Arc::new(MockHttpClient::new(move |actual| {
233233
let credential = credential.clone();
234234
async move {

sdk/core/azure_core/src/http/policies/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ mod client_request_id;
88
mod instrumentation;
99
mod user_agent;
1010

11-
pub use bearer_token_policy::BearerTokenCredentialPolicy;
11+
pub use bearer_token_policy::BearerTokenAuthorizationPolicy;
1212
pub use client_request_id::*;
1313
pub use instrumentation::*;
1414
pub use typespec_client_core::http::policies::*;

sdk/core/azure_core_macros/src/tracing_new.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ mod tests {
542542
));
543543
}
544544
endpoint.set_query(None);
545-
let auth_policy: Arc<dyn Policy> = Arc::new(BearerTokenCredentialPolicy::new(
545+
let auth_policy: Arc<dyn Policy> = Arc::new(BearerTokenAuthorizationPolicy::new(
546546
credential,
547547
vec!["https://vault.azure.net/.default"],
548548
));
@@ -581,7 +581,7 @@ mod tests {
581581
));
582582
}
583583
endpoint.set_query(None);
584-
let auth_policy: Arc<dyn Policy> = Arc::new(BearerTokenCredentialPolicy::new(
584+
let auth_policy: Arc<dyn Policy> = Arc::new(BearerTokenAuthorizationPolicy::new(
585585
credential,
586586
vec!["https://vault.azure.net/.default"],
587587
));
@@ -635,7 +635,7 @@ mod tests {
635635
));
636636
}
637637
endpoint.set_query(None);
638-
let auth_policy: Arc<dyn Policy> = Arc::new(BearerTokenCredentialPolicy::new(
638+
let auth_policy: Arc<dyn Policy> = Arc::new(BearerTokenAuthorizationPolicy::new(
639639
credential,
640640
vec!["https://vault.azure.net/.default"],
641641
));
@@ -674,7 +674,7 @@ mod tests {
674674
));
675675
}
676676
endpoint.set_query(None);
677-
let auth_policy: Arc<dyn Policy> = Arc::new(BearerTokenCredentialPolicy::new(
677+
let auth_policy: Arc<dyn Policy> = Arc::new(BearerTokenAuthorizationPolicy::new(
678678
credential,
679679
vec!["https://vault.azure.net/.default"],
680680
));

sdk/keyvault/azure_security_keyvault_certificates/src/generated/clients/certificate_client.rs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/keyvault/azure_security_keyvault_keys/src/generated/clients/key_client.rs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/keyvault/azure_security_keyvault_secrets/src/generated/clients/secret_client.rs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/storage/azure_storage_blob/src/clients/append_blob_client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::{
1515
use azure_core::{
1616
credentials::TokenCredential,
1717
http::{
18-
policies::{BearerTokenCredentialPolicy, Policy},
18+
policies::{BearerTokenAuthorizationPolicy, Policy},
1919
NoFormat, Pipeline, RequestContent, Response, Url,
2020
},
2121
tracing, Bytes, Result,
@@ -56,7 +56,7 @@ impl GeneratedAppendBlobClient {
5656
format!("{blob_url} must use https"),
5757
));
5858
}
59-
let auth_policy: Arc<dyn Policy> = Arc::new(BearerTokenCredentialPolicy::new(
59+
let auth_policy: Arc<dyn Policy> = Arc::new(BearerTokenAuthorizationPolicy::new(
6060
token_credential,
6161
vec!["https://storage.azure.com/.default"],
6262
));

sdk/storage/azure_storage_blob/src/clients/blob_client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use azure_core::{
2929
credentials::TokenCredential,
3030
error::ErrorKind,
3131
http::{
32-
policies::{BearerTokenCredentialPolicy, Policy},
32+
policies::{BearerTokenAuthorizationPolicy, Policy},
3333
AsyncResponse, JsonFormat, NoFormat, Pipeline, RequestContent, Response, StatusCode, Url,
3434
XmlFormat,
3535
},
@@ -72,7 +72,7 @@ impl GeneratedBlobClient {
7272
format!("{blob_url} must use https"),
7373
));
7474
}
75-
let auth_policy: Arc<dyn Policy> = Arc::new(BearerTokenCredentialPolicy::new(
75+
let auth_policy: Arc<dyn Policy> = Arc::new(BearerTokenAuthorizationPolicy::new(
7676
token_credential,
7777
vec!["https://storage.azure.com/.default"],
7878
));

sdk/storage/azure_storage_blob/src/clients/blob_container_client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use azure_core::{
2424
credentials::TokenCredential,
2525
error::ErrorKind,
2626
http::{
27-
policies::{BearerTokenCredentialPolicy, Policy},
27+
policies::{BearerTokenAuthorizationPolicy, Policy},
2828
NoFormat, PageIterator, Pager, Pipeline, Response, StatusCode, Url, XmlFormat,
2929
},
3030
tracing, Result,
@@ -65,7 +65,7 @@ impl GeneratedBlobContainerClient {
6565
format!("{container_url} must use https"),
6666
));
6767
}
68-
let auth_policy: Arc<dyn Policy> = Arc::new(BearerTokenCredentialPolicy::new(
68+
let auth_policy: Arc<dyn Policy> = Arc::new(BearerTokenAuthorizationPolicy::new(
6969
token_credential,
7070
vec!["https://storage.azure.com/.default"],
7171
));

0 commit comments

Comments
 (0)