Skip to content

Commit

Permalink
Fix tests broken by #403 (#410)
Browse files Browse the repository at this point in the history
  • Loading branch information
chlowell authored Apr 18, 2023
1 parent 2d23419 commit 6a16f64
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions apps/internal/base/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,16 +235,16 @@ func TestCacheIOErrors(t *testing.T) {
if !errors.Is(actual, expected) {
t.Fatalf(`expected "%v", got "%v"`, expected, actual)
}
_, actual = client.AcquireTokenSilent(ctx, AcquireTokenSilentParameters{})
_, actual = client.AcquireTokenSilent(ctx, AcquireTokenSilentParameters{Scopes: testScopes})
if cache.replaceErr != nil && !errors.Is(actual, expected) {
t.Fatalf(`expected "%v", got "%v"`, expected, actual)
}
}
_, actual := client.AcquireTokenByAuthCode(ctx, AcquireTokenAuthCodeParameters{AppType: accesstokens.ATConfidential})
_, actual := client.AcquireTokenByAuthCode(ctx, AcquireTokenAuthCodeParameters{AppType: accesstokens.ATConfidential, Scopes: testScopes})
if !errors.Is(actual, expected) {
t.Fatalf(`expected "%v", got "%v"`, expected, actual)
}
_, actual = client.AcquireTokenOnBehalfOf(ctx, AcquireTokenOnBehalfOfParameters{Credential: &accesstokens.Credential{Secret: "..."}})
_, actual = client.AcquireTokenOnBehalfOf(ctx, AcquireTokenOnBehalfOfParameters{Credential: &accesstokens.Credential{Secret: "..."}, Scopes: testScopes})
if !errors.Is(actual, expected) {
t.Fatalf(`expected "%v", got "%v"`, expected, actual)
}
Expand Down
10 changes: 6 additions & 4 deletions apps/internal/oauth/oauth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
"github.com/AzureAD/microsoft-authentication-library-for-go/apps/internal/oauth/ops/authority"
)

var testScopes = []string{"scope"}

func TestAuthCode(t *testing.T) {
tests := []struct {
desc string
Expand Down Expand Up @@ -56,7 +58,7 @@ func TestAuthCode(t *testing.T) {
token.AccessTokens = test.at
token.Resolver = test.re

_, err := token.AuthCode(context.Background(), accesstokens.AuthCodeRequest{})
_, err := token.AuthCode(context.Background(), accesstokens.AuthCodeRequest{AuthParams: authority.AuthParams{Scopes: testScopes}})
switch {
case err == nil && test.err:
t.Errorf("TestAuthCode(%s): got err == nil, want err != nil", test.desc)
Expand Down Expand Up @@ -183,7 +185,7 @@ func TestRefresh(t *testing.T) {
_, err := token.Refresh(
context.Background(),
accesstokens.ATPublic,
authority.AuthParams{},
authority.AuthParams{Scopes: testScopes},
&accesstokens.Credential{},
accesstokens.RefreshToken{},
)
Expand Down Expand Up @@ -263,7 +265,7 @@ func TestUsernamePassword(t *testing.T) {
token.Resolver = test.re
token.WSTrust = test.ws

_, err := token.UsernamePassword(context.Background(), authority.AuthParams{})
_, err := token.UsernamePassword(context.Background(), authority.AuthParams{Scopes: testScopes})
switch {
case err == nil && test.err:
t.Errorf("TestUsernamePassword(%s): got err == nil, want err != nil", test.desc)
Expand Down Expand Up @@ -382,7 +384,7 @@ func TestDeviceCodeToken(t *testing.T) {
token.AccessTokens = test.at
token.Resolver = test.re

dc, err := token.DeviceCode(context.Background(), authority.AuthParams{})
dc, err := token.DeviceCode(context.Background(), authority.AuthParams{Scopes: testScopes})
switch {
case err == nil && test.err:
t.Errorf("TestDeviceCodeToken(%s): got err == nil, want err != nil", test.desc)
Expand Down

0 comments on commit 6a16f64

Please sign in to comment.