Skip to content

Commit 4023764

Browse files
authored
Use "With" instead of "From" in OBO constructors (Azure#20688)
1 parent 96ab779 commit 4023764

File tree

5 files changed

+12
-10
lines changed

5 files changed

+12
-10
lines changed

sdk/azidentity/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
### Breaking Changes
88
> These changes affect only code written against a beta version such as v1.3.0-beta.5
99
* Renamed `DisableInstanceDiscovery` to `DisableAuthorityValidationAndInstanceDiscovery`
10+
* Renamed `NewOnBehalfOfCredentialFromCertificate` to `NewOnBehalfOfCredentialWithCertificate`
11+
* Renamed `NewOnBehalfOfCredentialFromSecret` to `NewOnBehalfOfCredentialWithSecret`
1012

1113
### Bugs Fixed
1214

sdk/azidentity/azidentity_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ func TestAdditionallyAllowedTenants(t *testing.T) {
373373
AdditionallyAllowedTenants: test.allowed,
374374
ClientOptions: co,
375375
}
376-
return NewOnBehalfOfCredentialFromSecret(fakeTenantID, fakeClientID, "assertion", fakeSecret, &o)
376+
return NewOnBehalfOfCredentialWithSecret(fakeTenantID, fakeClientID, "assertion", fakeSecret, &o)
377377
},
378378
},
379379
{
@@ -596,7 +596,7 @@ func TestClaims(t *testing.T) {
596596
name: credNameOBO,
597597
ctor: func(co azcore.ClientOptions) (azcore.TokenCredential, error) {
598598
o := OnBehalfOfCredentialOptions{ClientOptions: co}
599-
return NewOnBehalfOfCredentialFromSecret(fakeTenantID, fakeClientID, "assertion", fakeSecret, &o)
599+
return NewOnBehalfOfCredentialWithSecret(fakeTenantID, fakeClientID, "assertion", fakeSecret, &o)
600600
},
601601
},
602602
{

sdk/azidentity/example_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
1313
)
1414

15-
func ExampleNewOnBehalfOfCredentialFromCertificate() {
15+
func ExampleNewOnBehalfOfCredentialWithCertificate() {
1616
data, err := os.ReadFile(certPath)
1717
if err != nil {
1818
// TODO: handle error

sdk/azidentity/on_behalf_of_credential.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,18 @@ type OnBehalfOfCredentialOptions struct {
5050
SendCertificateChain bool
5151
}
5252

53-
// NewOnBehalfOfCredentialFromCertificate constructs an OnBehalfOfCredential that authenticates with a certificate.
53+
// NewOnBehalfOfCredentialWithCertificate constructs an OnBehalfOfCredential that authenticates with a certificate.
5454
// See [ParseCertificates] for help loading a certificate.
55-
func NewOnBehalfOfCredentialFromCertificate(tenantID, clientID, userAssertion string, certs []*x509.Certificate, key crypto.PrivateKey, options *OnBehalfOfCredentialOptions) (*OnBehalfOfCredential, error) {
55+
func NewOnBehalfOfCredentialWithCertificate(tenantID, clientID, userAssertion string, certs []*x509.Certificate, key crypto.PrivateKey, options *OnBehalfOfCredentialOptions) (*OnBehalfOfCredential, error) {
5656
cred, err := confidential.NewCredFromCert(certs, key)
5757
if err != nil {
5858
return nil, err
5959
}
6060
return newOnBehalfOfCredential(tenantID, clientID, userAssertion, cred, options)
6161
}
6262

63-
// NewOnBehalfOfCredentialFromSecret constructs an OnBehalfOfCredential that authenticates with a client secret.
64-
func NewOnBehalfOfCredentialFromSecret(tenantID, clientID, userAssertion, clientSecret string, options *OnBehalfOfCredentialOptions) (*OnBehalfOfCredential, error) {
63+
// NewOnBehalfOfCredentialWithSecret constructs an OnBehalfOfCredential that authenticates with a client secret.
64+
func NewOnBehalfOfCredentialWithSecret(tenantID, clientID, userAssertion, clientSecret string, options *OnBehalfOfCredentialOptions) (*OnBehalfOfCredential, error) {
6565
cred, err := confidential.NewCredFromSecret(clientSecret)
6666
if err != nil {
6767
return nil, err

sdk/azidentity/on_behalf_of_credential_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,23 @@ func TestOnBehalfOfCredential(t *testing.T) {
2929
ctor: func(tp policy.Transporter) (*OnBehalfOfCredential, error) {
3030
certs, key := allCertTests[0].certs, allCertTests[0].key
3131
o := OnBehalfOfCredentialOptions{ClientOptions: policy.ClientOptions{Transport: tp}}
32-
return NewOnBehalfOfCredentialFromCertificate(fakeTenantID, fakeClientID, expectedAssertion, certs, key, &o)
32+
return NewOnBehalfOfCredentialWithCertificate(fakeTenantID, fakeClientID, expectedAssertion, certs, key, &o)
3333
},
3434
name: "certificate",
3535
},
3636
{
3737
ctor: func(tp policy.Transporter) (*OnBehalfOfCredential, error) {
3838
certs, key := allCertTests[0].certs, allCertTests[0].key
3939
o := OnBehalfOfCredentialOptions{ClientOptions: policy.ClientOptions{Transport: tp}, SendCertificateChain: true}
40-
return NewOnBehalfOfCredentialFromCertificate(fakeTenantID, fakeClientID, expectedAssertion, certs, key, &o)
40+
return NewOnBehalfOfCredentialWithCertificate(fakeTenantID, fakeClientID, expectedAssertion, certs, key, &o)
4141
},
4242
name: "SNI",
4343
sendX5C: true,
4444
},
4545
{
4646
ctor: func(tp policy.Transporter) (*OnBehalfOfCredential, error) {
4747
o := OnBehalfOfCredentialOptions{ClientOptions: policy.ClientOptions{Transport: tp}}
48-
return NewOnBehalfOfCredentialFromSecret(fakeTenantID, fakeClientID, expectedAssertion, "secret", &o)
48+
return NewOnBehalfOfCredentialWithSecret(fakeTenantID, fakeClientID, expectedAssertion, "secret", &o)
4949
},
5050
name: "secret",
5151
},

0 commit comments

Comments
 (0)