61 lines
1.8 KiB
C#
61 lines
1.8 KiB
C#
using System;
|
|
using Xunit;
|
|
using Newtonsoft.Json.Linq;
|
|
using FluentAssertions;
|
|
|
|
namespace raven_integration
|
|
{
|
|
|
|
public class Auth
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
[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);
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
[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);
|
|
}
|
|
|
|
|
|
//==================================================
|
|
|
|
}//eoc
|
|
}//eons
|
|
|