yavsc/test/yavscTests/Mandatory/Remoting.cs

76 lines
2.4 KiB
C#

7 years ago
// // YavscWorkInProgress.cs
// /*
// paul 21/06/2018 10:11 20182018 6 21
// */
using System.Net;
5 months ago
using isnd.tests;
7 years ago
using Xunit;
7 years ago
using Xunit.Abstractions;
using Yavsc.Authentication;
7 years ago
5 years ago
namespace yavscTests
7 years ago
{
[Collection("Yavsc Work In Progress")]
5 years ago
[Trait("regression", "oui")]
5 months ago
public class Remoting : BaseTestContext, IClassFixture<WebServerFixture>
7 years ago
{
5 months ago
public Remoting(WebServerFixture serverFixture, ITestOutputHelper output)
7 years ago
: base(output, serverFixture)
7 years ago
{
5 months ago
7 years ago
}
7 years ago
[Theory]
7 years ago
[MemberData(nameof(GetLoginIntentData), parameters: 1)]
public async Task TestUserMayLogin
(
string clientId,
7 years ago
string clientSecret,
string scope,
string authorizeUrl,
string redirectUrl,
5 years ago
string accessTokenUrl
)
{
7 years ago
try
{
var oauthor = new OAuthenticator(clientId, clientSecret, scope,
new Uri(authorizeUrl), new Uri(redirectUrl), new Uri(accessTokenUrl));
5 years ago
var query = new Dictionary<string, string>
{
5 months ago
["Username"] = _serverFixture.TestingSetup.ValidCreds.UserName,
["Password"] = _serverFixture.TestingSetup.ValidCreds.Password,
["GrantType"] = "Password"
5 years ago
};
7 years ago
var result = await oauthor.RequestAccessTokenAsync(query);
Console.WriteLine(">> Got an output");
5 months ago
Console.WriteLine( "AccessToken " + result["AccessToken"]);
Console.WriteLine("TokenType " + result["TokenType"]);
Console.WriteLine("ExpiresIn " + result["ExpiresIn"]);
Console.WriteLine("RefreshToken : " + result["RefreshToken"]);
7 years ago
7 years ago
}
catch (Exception ex)
{
var webex = ex as WebException;
if (webex != null && webex.Status == (WebExceptionStatus)400)
{
5 months ago
if (_serverFixture.TestingSetup.ValidCreds.UserName == "lame-user")
7 years ago
{
Console.WriteLine("Bad pass joe!");
return;
7 years ago
}
}
throw;
}
7 years ago
}
7 years ago
5 months ago
public static IEnumerable<object[]> GetLoginIntentData(int count)
{
return new object[][] {new object[]{ "", "", "", "", "", "" } };
}
7 years ago
}
}