mirror of
https://github.com/actions/runner.git
synced 2025-12-13 19:03:44 +00:00
Remove runner flow: Change from PAT to "deletion token" in prompt (#225)
* Updating prompt deletion token Currently if you leave the token off the command, we're showing "Enter your personal access token:" Which won't work. This updates prompt to "deletion token" * Call correct function in test * Fix command text in test
This commit is contained in:
committed by
Tingluo Huang
parent
9bbbca9e5d
commit
d778f13dee
@@ -224,6 +224,15 @@ namespace GitHub.Runner.Listener
|
|||||||
validator: Validators.NonEmptyValidator);
|
validator: Validators.NonEmptyValidator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetRunnerDeletionToken()
|
||||||
|
{
|
||||||
|
return GetArgOrPrompt(
|
||||||
|
name: Constants.Runner.CommandLine.Args.Token,
|
||||||
|
description: "Enter runner deletion token:",
|
||||||
|
defaultValue: string.Empty,
|
||||||
|
validator: Validators.NonEmptyValidator);
|
||||||
|
}
|
||||||
|
|
||||||
public string GetUrl(bool suppressPromptIfEmpty = false)
|
public string GetUrl(bool suppressPromptIfEmpty = false)
|
||||||
{
|
{
|
||||||
// Note, GetArg does not consume the arg (like GetArgOrPrompt does).
|
// Note, GetArg does not consume the arg (like GetArgOrPrompt does).
|
||||||
|
|||||||
@@ -443,7 +443,7 @@ namespace GitHub.Runner.Listener.Configuration
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var githubToken = command.GetToken();
|
var githubToken = command.GetRunnerDeletionToken();
|
||||||
GitHubAuthResult authResult = await GetTenantCredential(settings.GitHubUrl, githubToken);
|
GitHubAuthResult authResult = await GetTenantCredential(settings.GitHubUrl, githubToken);
|
||||||
creds = authResult.ToVssCredentials();
|
creds = authResult.ToVssCredentials();
|
||||||
Trace.Info("cred retrieved via GitHub auth");
|
Trace.Info("cred retrieved via GitHub auth");
|
||||||
|
|||||||
@@ -513,6 +513,33 @@ namespace GitHub.Runner.Common.Tests
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
[Trait("Level", "L0")]
|
||||||
|
[Trait("Category", nameof(CommandSettings))]
|
||||||
|
public void PromptsForRunnerDeletionToken()
|
||||||
|
{
|
||||||
|
using (TestHostContext hc = CreateTestContext())
|
||||||
|
{
|
||||||
|
// Arrange.
|
||||||
|
var command = new CommandSettings(hc, args: new string[0]);
|
||||||
|
_promptManager
|
||||||
|
.Setup(x => x.ReadValue(
|
||||||
|
Constants.Runner.CommandLine.Args.Token, // argName
|
||||||
|
"Enter runner deletion token:", // description
|
||||||
|
true, // secret
|
||||||
|
string.Empty, // defaultValue
|
||||||
|
Validators.NonEmptyValidator, // validator
|
||||||
|
false)) // unattended
|
||||||
|
.Returns("some token");
|
||||||
|
|
||||||
|
// Act.
|
||||||
|
string actual = command.GetRunnerDeletionToken();
|
||||||
|
|
||||||
|
// Assert.
|
||||||
|
Assert.Equal("some token", actual);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
[Trait("Level", "L0")]
|
[Trait("Level", "L0")]
|
||||||
[Trait("Category", nameof(CommandSettings))]
|
[Trait("Category", nameof(CommandSettings))]
|
||||||
|
|||||||
Reference in New Issue
Block a user