yavsc/test/yavscTests/Mandatory/Remoting.cs

75 lines
2.4 KiB
C#
Raw Normal View History

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