re testing
This commit is contained in:
@ -42,17 +42,6 @@ namespace isn.tests
|
|||||||
var pub = model.Resources.FirstOrDefault((r) => r.Type.StartsWith("PackagePublish/"));
|
var pub = model.Resources.FirstOrDefault((r) => r.Type.StartsWith("PackagePublish/"));
|
||||||
Assert.True(pub != null);
|
Assert.True(pub != null);
|
||||||
}
|
}
|
||||||
[Fact]
|
|
||||||
public void TestSetApiKey()
|
|
||||||
{
|
|
||||||
string source = "http://localhost:3002/v3/index.json";
|
|
||||||
|
|
||||||
var setting = Settings.Create();
|
|
||||||
setting.Sources[source] = new SourceSettings{ Url=source };
|
|
||||||
string testingKey = "CfDJ8LF3SbIJ4FJAgs7uIQKhdCAYCNVXRwU6TEoaXOo1_ZpG2u8TCGFP2z13hw9xR0LC0gdbr1QGwNndiXUl4DI74nxyBi-T1oC33PWtE-5vgiJWeCH223PYtoSEdzDiWovwJZWJbQON0WqoG8vSfbrBXTmicD6oxF4ghwXXexY0RiRR";
|
|
||||||
|
|
||||||
Assert.Equal(testingKey, setting.Sources[source].ApiKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -183,7 +183,7 @@ namespace isnd.host.tests
|
|||||||
PackageUpdateResource pushRes = await repository.GetResourceAsync<PackageUpdateResource>();
|
PackageUpdateResource pushRes = await repository.GetResourceAsync<PackageUpdateResource>();
|
||||||
SymbolPackageUpdateResourceV3 symbolPackageResource = await repository.GetResourceAsync<SymbolPackageUpdateResourceV3>();
|
SymbolPackageUpdateResourceV3 symbolPackageResource = await repository.GetResourceAsync<SymbolPackageUpdateResourceV3>();
|
||||||
|
|
||||||
await pushRes.Push(new List<string>{ "../../../../../src/isn.abst/bin/Release/isn.abst.1.0.1.nupkg" }, null,
|
await pushRes.Push(new List<string>{ "../../../Yavsc.Abstract.1.0.8.nupkg" }, null,
|
||||||
5000, false, GetApiKey, GetSymbolsApiKey, false, false, symbolPackageResource, logger);
|
5000, false, GetApiKey, GetSymbolsApiKey, false, false, symbolPackageResource, logger);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,6 @@ namespace isnd.tests
|
|||||||
|
|
||||||
public IDataProtector DataProtector { get; private set; }
|
public IDataProtector DataProtector { get; private set; }
|
||||||
|
|
||||||
public ApplicationDbContext dbContext { get; private set; }
|
|
||||||
|
|
||||||
public string TestingUserName { get; private set; }
|
public string TestingUserName { get; private set; }
|
||||||
public string ProtectedTestingApiKey { get; internal set; }
|
public string ProtectedTestingApiKey { get; internal set; }
|
||||||
@ -80,15 +79,18 @@ namespace isnd.tests
|
|||||||
|
|
||||||
DataProtector = Host.Services.GetRequiredService<IDataProtectionProvider>()
|
DataProtector = Host.Services.GetRequiredService<IDataProtectionProvider>()
|
||||||
.CreateProtector(siteSettings.ProtectionTitle);
|
.CreateProtector(siteSettings.ProtectionTitle);
|
||||||
|
using IServiceScope scope = Host.Services.CreateScope();
|
||||||
|
ApplicationDbContext dbContext =
|
||||||
|
scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
|
||||||
|
|
||||||
dbContext = Host.Services.GetRequiredService<ApplicationDbContext>();
|
|
||||||
TestingUserName = "Tester";
|
TestingUserName = "Tester";
|
||||||
TestingUser = dbContext.Users.FirstOrDefault(u => u.UserName == TestingUserName);
|
TestingUser = dbContext.Users.FirstOrDefault(u => u.UserName == TestingUserName);
|
||||||
EnsureUser(TestingUserName);
|
EnsureUser(TestingUserName);
|
||||||
var testKey = dbContext.ApiKeys.FirstOrDefault(k => k.UserId == TestingUser.Id);
|
var testKey = dbContext.ApiKeys.FirstOrDefault(k => k.UserId == TestingUser.Id);
|
||||||
if (testKey == null)
|
if (testKey == null)
|
||||||
{
|
{
|
||||||
var keyProvider = Host.Services.GetService<IApiKeyProvider>();
|
var keyProvider = scope.ServiceProvider.GetService<IApiKeyProvider>();
|
||||||
var apiKeyQuery = new Data.ApiKeys.CreateModel
|
var apiKeyQuery = new Data.ApiKeys.CreateModel
|
||||||
{
|
{
|
||||||
Name = "Testing Key",
|
Name = "Testing Key",
|
||||||
@ -111,7 +113,12 @@ namespace isnd.tests
|
|||||||
{
|
{
|
||||||
if (TestingUser == null)
|
if (TestingUser == null)
|
||||||
{
|
{
|
||||||
var userManager = Host.Services.GetRequiredService<UserManager<ApplicationUser>>();
|
using IServiceScope scope = Host.Services.CreateScope();
|
||||||
|
|
||||||
|
var userManager =
|
||||||
|
scope.ServiceProvider.GetRequiredService<UserManager<ApplicationUser>>();
|
||||||
|
|
||||||
|
|
||||||
TestingUser = new ApplicationUser
|
TestingUser = new ApplicationUser
|
||||||
{
|
{
|
||||||
UserName = testingUserName
|
UserName = testingUserName
|
||||||
@ -120,6 +127,9 @@ namespace isnd.tests
|
|||||||
var result = userManager.CreateAsync(TestingUser).Result;
|
var result = userManager.CreateAsync(TestingUser).Result;
|
||||||
|
|
||||||
Assert.True(result.Succeeded);
|
Assert.True(result.Succeeded);
|
||||||
|
|
||||||
|
ApplicationDbContext dbContext =
|
||||||
|
scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
|
||||||
TestingUser = dbContext.Users.FirstOrDefault(u => u.UserName == testingUserName);
|
TestingUser = dbContext.Users.FirstOrDefault(u => u.UserName == testingUserName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,5 +18,6 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\src\isnd\isnd.csproj" />
|
<ProjectReference Include="..\..\src\isnd\isnd.csproj" />
|
||||||
<ProjectReference Include="..\..\src\isn\isn.csproj" />
|
<ProjectReference Include="..\..\src\isn\isn.csproj" />
|
||||||
|
<File Include="Yavsc.Abstract.1.0.8.nupkg"></File>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
Reference in New Issue
Block a user