about to test remote access
This commit is contained in:
parent
47323b2d85
commit
d21337d4a6
8 changed files with 86 additions and 81 deletions
|
|
@ -1,9 +1,8 @@
|
|||
using isnd.tests;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Net.Security;
|
||||
using isnd.tests;
|
||||
using Xunit.Abstractions;
|
||||
using IdentityModel.Client;
|
||||
using System.Net;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Net.Security;
|
||||
|
||||
namespace yavscTests
|
||||
{
|
||||
|
|
@ -20,64 +19,55 @@ namespace yavscTests
|
|||
|
||||
[Fact]
|
||||
public async Task ObtainServiceToken()
|
||||
{
|
||||
var serverUrl = _serverFixture.Addresses.FirstOrDefault(
|
||||
u => u.StartsWith("https:")
|
||||
);
|
||||
{
|
||||
var serverUrl = _serverFixture.Addresses.FirstOrDefault(u => u.StartsWith("https:"));
|
||||
if (string.IsNullOrEmpty(serverUrl))
|
||||
throw new InvalidOperationException("No HTTPS server address found");
|
||||
|
||||
HttpClient client = NewHttpClient();
|
||||
var disco = await client.GetDiscoveryDocumentAsync(serverUrl);
|
||||
if (disco.IsError) throw new Exception(disco.Error);
|
||||
|
||||
String authority = _serverFixture.SiteSettings.Authority;
|
||||
HttpClient client = NewHttpClient();
|
||||
var disco = await client.GetDiscoveryDocumentAsync(authority);
|
||||
if (disco.IsError) throw new Exception(disco.Error);
|
||||
|
||||
var response = await client.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest
|
||||
{
|
||||
Address = disco.TokenEndpoint,
|
||||
ClientId = _serverFixture.TestClientId,
|
||||
ClientSecret = _serverFixture.TestClientSecret,
|
||||
Scope = "test",
|
||||
GrantType = "client_credentials"
|
||||
});
|
||||
/*"mvc";
|
||||
options.ClientSecret = "49C1A7E1-0C79-4A89-A3D6-A37998FB86B0";*/
|
||||
if (response.IsError) throw new Exception(response.Error);
|
||||
|
||||
}
|
||||
var response = await client.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest
|
||||
{
|
||||
Address = disco.TokenEndpoint,
|
||||
ClientId = _serverFixture.TestClientId,
|
||||
ClientSecret = _serverFixture.TestClientSecret,
|
||||
Scope = "test",
|
||||
GrantType = "client_credentials"
|
||||
});
|
||||
if (response.IsError) throw new Exception(response.Error);
|
||||
}
|
||||
|
||||
private static HttpClient NewHttpClient()
|
||||
{
|
||||
return new HttpClient(new BypassSslValidationHandler());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Fact]
|
||||
public async Task ObtainResourceOwnerPasswordToken()
|
||||
{
|
||||
var serverUrl = _serverFixture.Addresses.FirstOrDefault(
|
||||
u => u.StartsWith("https:")
|
||||
);
|
||||
|
||||
String authority = _serverFixture.SiteSettings.Authority;
|
||||
var serverUrl = _serverFixture.Addresses.FirstOrDefault(u => u.StartsWith("https:"));
|
||||
if (string.IsNullOrEmpty(serverUrl))
|
||||
throw new InvalidOperationException("No HTTPS server address found");
|
||||
|
||||
var client = NewHttpClient();
|
||||
var disco = await client.GetDiscoveryDocumentAsync(authority);
|
||||
var disco = await client.GetDiscoveryDocumentAsync(serverUrl);
|
||||
if (disco.IsError) throw new Exception(disco.Error);
|
||||
|
||||
var response = await client.RequestPasswordTokenAsync(new PasswordTokenRequest
|
||||
{
|
||||
Address = disco.TokenEndpoint,
|
||||
|
||||
ClientId = _serverFixture.TestClientId,
|
||||
ClientSecret = _serverFixture.TestClientSecret,
|
||||
|
||||
UserName = _serverFixture.TestingUserName,
|
||||
Password = _serverFixture.TestingUserPassword,
|
||||
|
||||
Scope = "test",
|
||||
|
||||
Parameters =
|
||||
{
|
||||
Address = disco.TokenEndpoint,
|
||||
ClientId = _serverFixture.TestClientId,
|
||||
ClientSecret = _serverFixture.TestClientSecret,
|
||||
UserName = _serverFixture.TestingUserName,
|
||||
Password = _serverFixture.TestingUserPassword,
|
||||
Scope = "test",
|
||||
Parameters =
|
||||
{
|
||||
{ "acr_values", "tenant:custom_account_store1 foo bar quux" }
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if (response.IsError) throw new Exception(response.Error);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,20 +1,24 @@
|
|||
using IdentityServer8.EntityFramework.Entities;
|
||||
using IdentityServer8.Models;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting.Server;
|
||||
using Microsoft.AspNetCore.Hosting.Server.Features;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Yavsc;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Extensions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Serilog;
|
||||
using Serilog.Events;
|
||||
using Serilog.Sinks.SystemConsole.Themes;
|
||||
using IdentityServer8.EntityFramework.Entities;
|
||||
using IdentityServer8.Models;
|
||||
using System.Net;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using Yavsc;
|
||||
using Yavsc.Extensions;
|
||||
using Yavsc.Models;
|
||||
using Client = IdentityServer8.EntityFramework.Entities.Client;
|
||||
|
||||
namespace isnd.tests
|
||||
|
|
@ -88,6 +92,7 @@ namespace isnd.tests
|
|||
["Smtp:SenderName"] = "Yavsc Test",
|
||||
["Smtp:SenderEmail"] = "test@example.com"
|
||||
});
|
||||
|
||||
Configuration = builder.Configuration;
|
||||
|
||||
this.app = builder.ConfigureWebAppServices();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"Site": {
|
||||
"Authority": "localhost",
|
||||
"Authority": "https://localhost",
|
||||
"Title": "Yavsc dev",
|
||||
"Slogan": "Yavsc : WIP.",
|
||||
"Banner": "/images/yavsc.png",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue