using System;
using Xunit;
using Newtonsoft.Json.Linq;
using FluentAssertions;
namespace raven_integration
{
public class Auth
{
///
///
///
[Fact]
public async void BadLoginShouldNotWork()
{
//Expect status code 401 and result:
// {{
// "error": {
// "code": "2003",
// "message": "Authentication failed"
// }
// }}
dynamic d = new JObject();
d.login = "BOGUS";
d.password = "ACCOUNT";
ApiResponse a = await Util.PostAsync("Auth", null, d.ToString());
Util.ValidateErrorCodeResponse(a, 2003, 401);
}
///
///
///
[Fact]
public async void JWTExpiredTokenShouldFail()
{
//Valid auth token but expired:
var ValidButExpiredToken="Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOiIxNTQ0NTU5NzAwIiwiZXhwIjoiMTU0NzE1MTcwMCIsImlzcyI6ImF5YW5vdmEuY29tIiwiaWQiOiIxIiwiYXlhbm92YS9yb2xlcyI6IjMyNzY3In0.fMq_8Dvia63rzN_U2zjczPvUNM40OEAeI4VOeV6ulGw";
//Expect status code 401 and result:
// {{
// "error": {
// "code": "2003",
// "message": "Authentication failed"
// }
// }}
ApiResponse a = await Util.GetAsync("Locale/picklist", ValidButExpiredToken);//lowest level test user because there are no limits on this route except to be authenticated
Util.ValidateHTTPStatusCode(a, 401);
}
/*
case "EXPIRED":
exp = new DateTimeOffset(DateTime.Now.AddDays(-30).ToUniversalTime(), TimeSpan.Zero);
break;
case "WRONG_ISSUER":
Issuer = "Bogus";
break;
case "NO_ALGORITHM":
Algorithm = Jose.JwsAlgorithm.none;
break;
case "WRONG_SECRET":
secretKey = System.Text.Encoding.ASCII.GetBytes("xxxxxxThisIsObviouslyWrongxxxxxx");
break;
case "TRUNCATED_SIGNATURE":
PostTransform = true;
break;
case "TRANSPOSE_SIGNATURE":
PostTransform = true;
break;
}
*/
//==================================================
}//eoc
}//eons