|
|
|
@ -4,10 +4,13 @@
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
using System.IO;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Net;
|
|
|
|
using System.Net;
|
|
|
|
using System.Text;
|
|
|
|
using System.Text;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
using Microsoft.AspNet.Hosting;
|
|
|
|
|
|
|
|
using Microsoft.Extensions.PlatformAbstractions;
|
|
|
|
using Xunit;
|
|
|
|
using Xunit;
|
|
|
|
using Xunit.Abstractions;
|
|
|
|
using Xunit.Abstractions;
|
|
|
|
using Yavsc.Authentication;
|
|
|
|
using Yavsc.Authentication;
|
|
|
|
@ -22,6 +25,7 @@ namespace test
|
|
|
|
public Remoting(ServerSideFixture serverFixture, ITestOutputHelper output)
|
|
|
|
public Remoting(ServerSideFixture serverFixture, ITestOutputHelper output)
|
|
|
|
: base(output, serverFixture)
|
|
|
|
: base(output, serverFixture)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Theory]
|
|
|
|
[Theory]
|
|
|
|
@ -42,10 +46,14 @@ namespace test
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var oauthor = new OAuthenticator(clientId, clientSecret, scope,
|
|
|
|
var oauthor = new OAuthenticator(clientId, clientSecret, scope,
|
|
|
|
new Uri(authorizeUrl), new Uri(redirectUrl), new Uri(accessTokenUrl));
|
|
|
|
new Uri(authorizeUrl), new Uri(redirectUrl), new Uri(accessTokenUrl));
|
|
|
|
var query = new Dictionary<string, string>();
|
|
|
|
var query = new Dictionary<string, string>
|
|
|
|
query[Parameters.Username] = login;
|
|
|
|
{
|
|
|
|
query[Parameters.Password] = pass;
|
|
|
|
[Parameters.Username] = Startup.Testing.ValidCreds[0].UserName,
|
|
|
|
query[Parameters.GrantType] = GrantTypes.Password;
|
|
|
|
[Parameters.Password] = Startup.Testing.ValidCreds[0].Password,
|
|
|
|
|
|
|
|
[Parameters.GrantType] = GrantTypes.Password
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
EnsureWeb();
|
|
|
|
|
|
|
|
|
|
|
|
var result = await oauthor.RequestAccessTokenAsync(query);
|
|
|
|
var result = await oauthor.RequestAccessTokenAsync(query);
|
|
|
|
Console.WriteLine(">> Got an output");
|
|
|
|
Console.WriteLine(">> Got an output");
|
|
|
|
Console.WriteLine(Parameters.AccessToken + ": " + result[Parameters.AccessToken]);
|
|
|
|
Console.WriteLine(Parameters.AccessToken + ": " + result[Parameters.AccessToken]);
|
|
|
|
@ -68,50 +76,47 @@ namespace test
|
|
|
|
throw;
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public static string GetPassword()
|
|
|
|
internal static void EnsureWeb()
|
|
|
|
{
|
|
|
|
|
|
|
|
var pwd = new StringBuilder();
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var len = pwd.ToString().Length;
|
|
|
|
|
|
|
|
ConsoleKeyInfo i = Console.ReadKey(true);
|
|
|
|
|
|
|
|
if (i.Key == ConsoleKey.Enter)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (i.Key == ConsoleKey.Backspace)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (pwd.Length > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
pwd.Remove(len - 1, 1);
|
|
|
|
|
|
|
|
Console.Write("\b \b");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
pwd.Append(i.KeyChar);
|
|
|
|
DirectoryInfo di = new DirectoryInfo("../Yavsc");
|
|
|
|
Console.Write("*");
|
|
|
|
Environment.CurrentDirectory = di.FullName;
|
|
|
|
}
|
|
|
|
var host = new WebHostBuilder();
|
|
|
|
}
|
|
|
|
|
|
|
|
return pwd.ToString();
|
|
|
|
var hostengine = host
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.UseEnvironment("Development")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.UseServer("web")
|
|
|
|
|
|
|
|
.UseStartup<Yavsc.Startup>()
|
|
|
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
// hostengine.ApplicationServices
|
|
|
|
|
|
|
|
var startup = hostengine.Start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public static IEnumerable<object[]> GetLoginIntentData(int numTests)
|
|
|
|
public static IEnumerable<object[]> GetLoginIntentData(int numTests)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
var allData = new List<object[]>();
|
|
|
|
var allData = new List<object[]>();
|
|
|
|
Console.WriteLine($"Please, enter {numTests}:");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int iTest=0; iTest<numTests; iTest++)
|
|
|
|
for (int iTest=0; iTest < numTests && iTest < Startup.Testing.ValidCreds.Length; iTest++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Console.Write("Please, enter a login:");
|
|
|
|
|
|
|
|
var login = Console.ReadLine();
|
|
|
|
var login = Startup.Testing.ValidCreds[iTest].UserName;
|
|
|
|
Console.Write("Please, enter a pass:");
|
|
|
|
var pass = Startup.Testing.ValidCreds[iTest].Password;
|
|
|
|
var pass = GetPassword();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
allData.Add(new object[] { ServerSideFixture.ApiKey, "blouh", "profile",
|
|
|
|
allData.Add(new object[] { ServerSideFixture.ApiKey, "blouh", "profile",
|
|
|
|
"http://localhost:5000/authorize", "http://localhost:5000/oauth/success",
|
|
|
|
"http://localhost:5000/authorize", "http://localhost:5000/oauth/success",
|
|
|
|
"http://localhost:5000/token",login, pass});
|
|
|
|
"http://localhost:5000/token",login, pass});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var valid = allData.Count;
|
|
|
|
|
|
|
|
for (int iTest=0; iTest + valid < numTests && iTest < Startup.Testing.InvalidCreds.Length; iTest++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var login = Startup.Testing.InvalidCreds[iTest].UserName;
|
|
|
|
|
|
|
|
var pass = Startup.Testing.InvalidCreds[iTest].Password;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
allData.Add(new object[] { ServerSideFixture.ApiKey, "blouh", "profile",
|
|
|
|
|
|
|
|
"http://localhost:5000/authorize", "http://localhost:5000/oauth/success",
|
|
|
|
|
|
|
|
"http://localhost:5000/token",login, 0 });
|
|
|
|
|
|
|
|
}
|
|
|
|
return allData.Take(numTests);
|
|
|
|
return allData.Take(numTests);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|