|
|
@ -4,6 +4,7 @@
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
using System.Net;
|
|
|
|
using System.Net;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Xunit;
|
|
|
|
using Xunit;
|
|
|
@ -23,13 +24,7 @@ namespace test
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Theory]
|
|
|
|
[Theory]
|
|
|
|
[InlineData("d9be5e97-c19d-42e4-b444-0e65863b19e1","blouh","profile",
|
|
|
|
[MemberData(nameof(GetLoginIntentData), parameters: 1)]
|
|
|
|
"http://localhost:5000/authorize",
|
|
|
|
|
|
|
|
"http://localhost:5000/oauth/success",
|
|
|
|
|
|
|
|
"http://localhost:5000/token",
|
|
|
|
|
|
|
|
"joe",
|
|
|
|
|
|
|
|
"badpass"
|
|
|
|
|
|
|
|
)]
|
|
|
|
|
|
|
|
public async Task TestUserMayLogin
|
|
|
|
public async Task TestUserMayLogin
|
|
|
|
(
|
|
|
|
(
|
|
|
|
string clientId,
|
|
|
|
string clientId,
|
|
|
@ -42,7 +37,8 @@ namespace test
|
|
|
|
string pass
|
|
|
|
string pass
|
|
|
|
)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
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>();
|
|
|
@ -62,7 +58,8 @@ namespace test
|
|
|
|
var webex = ex as WebException;
|
|
|
|
var webex = ex as WebException;
|
|
|
|
if (webex != null && webex.Status == (WebExceptionStatus)400)
|
|
|
|
if (webex != null && webex.Status == (WebExceptionStatus)400)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (login == "joe") {
|
|
|
|
if (login == "joe")
|
|
|
|
|
|
|
|
{
|
|
|
|
Console.WriteLine("Bad pass joe!");
|
|
|
|
Console.WriteLine("Bad pass joe!");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -70,5 +67,35 @@ namespace test
|
|
|
|
throw;
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public struct LoginIntentData
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
public string clientId;
|
|
|
|
|
|
|
|
public string clientSecret;
|
|
|
|
|
|
|
|
public string scope;
|
|
|
|
|
|
|
|
public string authorizeUrl;
|
|
|
|
|
|
|
|
public string redirectUrl;
|
|
|
|
|
|
|
|
public string accessTokenUrl;
|
|
|
|
|
|
|
|
public string login;
|
|
|
|
|
|
|
|
public string pass;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public static IEnumerable<object[]> GetLoginIntentData(int numTests)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var allData = new List<object[]>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
new object[] {"d9be5e97-c19d-42e4-b444-0e65863b19e1", "blouh", "profile",
|
|
|
|
|
|
|
|
"http://localhost:5000/authorize", "http://localhost:5000/oauth/success",
|
|
|
|
|
|
|
|
"http://localhost:5000/token","joe", "badpass"
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
new object[] { -4, -6, -10 },
|
|
|
|
|
|
|
|
new object[] { -2, 2, 0 },
|
|
|
|
|
|
|
|
new object[] { int.MinValue, -1, int.MaxValue },
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return allData.Take(numTests);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|