testing
This commit is contained in:
@ -1,11 +1,6 @@
|
||||
// // YavscWorkInProgress.cs
|
||||
// /*
|
||||
// paul 21/06/2018 10:11 20182018 6 21
|
||||
// */
|
||||
using System.Net;
|
||||
using isnd.tests;
|
||||
using Xunit;
|
||||
using isnd.tests;
|
||||
using Xunit.Abstractions;
|
||||
using IdentityModel.Client;
|
||||
|
||||
namespace yavscTests
|
||||
{
|
||||
@ -27,45 +22,72 @@ namespace yavscTests
|
||||
string password
|
||||
)
|
||||
{
|
||||
try
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ObtainServiceToken()
|
||||
{
|
||||
var serverUrl = _serverFixture.Addresses.FirstOrDefault(
|
||||
u => u.StartsWith("https:")
|
||||
);
|
||||
|
||||
String authority = _serverFixture.SiteSettings.Authority;
|
||||
var client = new HttpClient();
|
||||
var disco = await client.GetDiscoveryDocumentAsync(authority);
|
||||
if (disco.IsError) throw new Exception(disco.Error);
|
||||
|
||||
var response = await client.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest
|
||||
{
|
||||
var serverUrl = _serverFixture.Addresses.FirstOrDefault(
|
||||
u => u.StartsWith("https:")
|
||||
);
|
||||
Address = disco.TokenEndpoint,
|
||||
|
||||
String auth = _serverFixture.SiteSettings.Authority;
|
||||
ClientId = "m2m.client", // _serverFixture.TestClientId,
|
||||
ClientSecret = "511536EF-F270-4058-80CA-1C89C192F69A" //_serverFixture.TestClientSecret,
|
||||
});
|
||||
/*"mvc";
|
||||
options.ClientSecret = "49C1A7E1-0C79-4A89-A3D6-A37998FB86B0";*/
|
||||
if (response.IsError) throw new Exception(response.Error);
|
||||
|
||||
|
||||
}
|
||||
|
||||
var query = new Dictionary<string, string>
|
||||
[Fact]
|
||||
public async Task ObtainResourceOwnerPasswordToken()
|
||||
{
|
||||
var serverUrl = _serverFixture.Addresses.FirstOrDefault(
|
||||
u => u.StartsWith("https:")
|
||||
);
|
||||
|
||||
String authority = _serverFixture.SiteSettings.Authority;
|
||||
var client = new HttpClient();
|
||||
var disco = await client.GetDiscoveryDocumentAsync(authority);
|
||||
if (disco.IsError) throw new Exception(disco.Error);
|
||||
|
||||
var response = await client.RequestPasswordTokenAsync(new PasswordTokenRequest
|
||||
{
|
||||
Address = disco.TokenEndpoint,
|
||||
|
||||
ClientId = "m2m.client",
|
||||
ClientSecret = "511536EF-F270-4058-80CA-1C89C192F69A",
|
||||
|
||||
UserName = _serverFixture.TestingUserName,
|
||||
Password = _serverFixture.TestingUserPassword,
|
||||
|
||||
Scope = "scope1",
|
||||
|
||||
Parameters =
|
||||
{
|
||||
["Username"] = userName,
|
||||
["Password"] = password,
|
||||
["GrantType"] = "password"
|
||||
};
|
||||
{ "acr_values", "tenant:custom_account_store1 foo bar quux" }
|
||||
}
|
||||
});
|
||||
|
||||
throw new NotImplementedException();
|
||||
if (response.IsError) throw new Exception(response.Error);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var webex = ex as WebException;
|
||||
if (webex != null)
|
||||
{
|
||||
if (webex.Status == WebExceptionStatus.ProtocolError)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> GetLoginIntentData()
|
||||
{
|
||||
return new object[][] { new object[] { "testuser", "test" } };
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user