build cli
This commit is contained in:
@ -6,11 +6,10 @@ using System.Net;
|
||||
using isnd.tests;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
using Yavsc.Authentication;
|
||||
|
||||
namespace yavscTests
|
||||
{
|
||||
[Collection("Yavsc Work In Progress")]
|
||||
[Collection("Yavsc Server")]
|
||||
[Trait("regression", "oui")]
|
||||
public class Remoting : BaseTestContext, IClassFixture<WebServerFixture>
|
||||
{
|
||||
@ -21,7 +20,7 @@ namespace yavscTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(GetLoginIntentData), parameters: 1)]
|
||||
[MemberData(nameof(GetLoginIntentData))]
|
||||
public async Task TestUserMayLogin
|
||||
(
|
||||
string userName,
|
||||
@ -30,54 +29,42 @@ namespace yavscTests
|
||||
{
|
||||
try
|
||||
{
|
||||
var serverUrl = _serverFixture.Addresses.FirstOrDefault();
|
||||
var serverUrl = _serverFixture.Addresses.FirstOrDefault(
|
||||
u => u.StartsWith("https:")
|
||||
);
|
||||
|
||||
String auth = _serverFixture.SiteSettings.Authority;
|
||||
|
||||
var oauthor = new OAuthenticator(_serverFixture.TestClientId, _serverFixture.TestClientSecret,
|
||||
"profile",
|
||||
new Uri(serverUrl), new Uri(serverUrl), new Uri(serverUrl+"/connect/token"));
|
||||
|
||||
|
||||
var query = new Dictionary<string, string>
|
||||
{
|
||||
["Username"] = userName,
|
||||
["Password"] = password,
|
||||
["GrantType"] = "Password"
|
||||
["GrantType"] = "password"
|
||||
};
|
||||
|
||||
var result = await oauthor.RequestAccessTokenAsync(query);
|
||||
Console.WriteLine(">> Got an output");
|
||||
Console.WriteLine( "AccessToken " + result["AccessToken"]);
|
||||
Console.WriteLine("TokenType " + result["TokenType"]);
|
||||
Console.WriteLine("ExpiresIn " + result["ExpiresIn"]);
|
||||
Console.WriteLine("RefreshToken : " + result["RefreshToken"]);
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var webex = ex as WebException;
|
||||
if (webex != null && webex.Status == (WebExceptionStatus)400)
|
||||
if (webex != null)
|
||||
{
|
||||
if (_serverFixture?.TestingSetup?.ValidCreds.UserName == "lame-user")
|
||||
if (webex.Status == WebExceptionStatus.ProtocolError)
|
||||
{
|
||||
Console.WriteLine("Bad pass joe!");
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> GetLoginIntentData(int countFakes = 0)
|
||||
public static IEnumerable<object[]> GetLoginIntentData()
|
||||
{
|
||||
if (countFakes == 0)
|
||||
return new object[][] { new object[] { "testuser", "test" } };
|
||||
|
||||
var fakUsers = new List<String[]>();
|
||||
for (int i = 0; i < countFakes; i++)
|
||||
{
|
||||
fakUsers.Add(new String[] { "fakeTester" + i, "pass" + i });
|
||||
}
|
||||
return fakUsers;
|
||||
return new object[][] { new object[] { "testuser", "test" } };
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user