allow again the push
This commit is contained in:
parent
38bb7e40ef
commit
a78847dbc9
5 changed files with 94 additions and 7 deletions
|
|
@ -21,6 +21,8 @@ namespace Isn.tests
|
|||
private readonly string configDirectory;
|
||||
private readonly string originalConfigDirectory;
|
||||
|
||||
public string LastApiKeyHeader { get; private set; }
|
||||
|
||||
public LocalSourceFixture()
|
||||
{
|
||||
var port = GetFreePort();
|
||||
|
|
@ -47,6 +49,11 @@ namespace Isn.tests
|
|||
break;
|
||||
}
|
||||
|
||||
if (context.Request.HttpMethod == "PUT")
|
||||
{
|
||||
LastApiKeyHeader = context.Request.Headers["X-NuGet-ApiKey"];
|
||||
}
|
||||
|
||||
var indexJson = JsonConvert.SerializeObject(new ApiIndexViewModel(prefix + "index.json")
|
||||
{
|
||||
Version = "3.0.0",
|
||||
|
|
@ -206,6 +213,22 @@ namespace Isn.tests
|
|||
Assert.Single(report);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PushUsesStoredApiKeyFromConfigWhenNoExplicitApiKeyIsProvided()
|
||||
{
|
||||
Program.LoadConfig();
|
||||
var clearApiKey = "stored-api-key";
|
||||
Program.Settings.Sources[fixture.SourceUrl].SetApiKey(clearApiKey);
|
||||
Program.SaveConfig();
|
||||
Program.LoadConfig();
|
||||
|
||||
var report = Program.PushPkg(new[] { Path.Combine(AppContext.BaseDirectory, "dummy.nupkg") });
|
||||
|
||||
Assert.NotNull(report);
|
||||
Assert.Single(report);
|
||||
Assert.Equal(clearApiKey, fixture.LastApiKeyHeader);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetServerResourcesUsingHttpClientAsyncTest()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -58,11 +58,21 @@ namespace isnd.host.tests
|
|||
const string clearValue = "legacy-api-key";
|
||||
var legacyProtectedValue = new Isn.DefaultDataProtector().Protect(clearValue);
|
||||
|
||||
var unprotected = ApiKeyProtector.UnprotectWithFallback(new ThrowingProtector(), legacyProtectedValue);
|
||||
var unprotected = ApiKeyProtector.TryUnprotectKey(new ThrowingProtector(), legacyProtectedValue);
|
||||
|
||||
Assert.Equal(clearValue, unprotected);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ApiKeyProtectorReturnsRawValueWhenInputIsNotProtected()
|
||||
{
|
||||
const string rawApiKey = "CfDJ8AstXUEkxpJBrmoENwy__WNPxqcOwAuxyYgiU3Mebns5yxAT3VrC5vTuWTRSGZBFB7IGUyFkUYsp2nhRy64NqeUzLgOwEcU4FPOf-yaAtPeTMeStRd60bRh2ZYyQkQ3hrhW-lwpCLwYtNOnOyX2jayuzByF-4QfHIEhg6lbWenzf";
|
||||
|
||||
var result = ApiKeyProtector.TryUnprotectKey(new ThrowingProtector(), rawApiKey);
|
||||
|
||||
Assert.Equal(rawApiKey, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
void TestDropUser()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue