Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ private static void GetFileNameAndArguments(string[] scopes, string tenantId, ou
string scopeArgs = string.Join(" ", scopes.Select(scope => $"--scope {scope}"));
string command = tenantId switch
{
null => $"azd auth token --output json {scopeArgs}",
_ => $"azd auth token --output json {scopeArgs} --tenant-id {tenantId}"
null => $"azd auth token --output json --no-prompt {scopeArgs}",
_ => $"azd auth token --output json --no-prompt {scopeArgs} --tenant-id {tenantId}"
};

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,22 @@ public async Task AuthenticateWithDeveloperCliCredential(
}
}

[Test]
public async Task AuthenticateWithDeveloperCliCredential_IncludesNoPromptFlag()
{
var context = new TokenRequestContext(new[] { Scope });
var (expectedToken, expectedExpiresOn, processOutput) = CredentialTestHelpers.CreateTokenForAzureDeveloperCli();

var testProcess = new TestProcess { Output = processOutput };
AzureDeveloperCliCredential credential =
InstrumentClient(new AzureDeveloperCliCredential(CredentialPipeline.GetInstance(null), new TestProcessService(testProcess, true)));
AccessToken actualToken = await credential.GetTokenAsync(context);

Assert.AreEqual(expectedToken, actualToken.Token);
Assert.AreEqual(expectedExpiresOn, actualToken.ExpiresOn);
Assert.That(testProcess.StartInfo.Arguments, Does.Contain("--no-prompt"));
}

[Test]
public void AuthenticateWithCliCredential_InvalidJsonOutput(
[Values("", "{}", "{\"Some\": false}", "{\"token\": \"token\"}", "{\"expiresOn\" : \"1900-01-01T00:00:00Z\"}")]
Expand Down