초기커밋
This commit is contained in:
45
BrokerApiTest/Jwt/JwtBasicTests.cs
Normal file
45
BrokerApiTest/Jwt/JwtBasicTests.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
|
||||
|
||||
//=============================================================================================
|
||||
// Jwt 토큰 생성 및 파싱 기본 라이브러리 사용 테스트
|
||||
//=============================================================================================
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Security.Claims;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
using BrokerCore.Common;
|
||||
using BrokerCore.Services;
|
||||
|
||||
namespace BrokerTest.Jwt;
|
||||
|
||||
public class JwtBasicTests
|
||||
{
|
||||
private readonly ITestOutputHelper m_test_output_helper;
|
||||
|
||||
public JwtBasicTests(ITestOutputHelper testOutputHelper)
|
||||
{
|
||||
m_test_output_helper = testOutputHelper;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void jwtServiceTest()
|
||||
{
|
||||
var jwt_option = new JwtOption
|
||||
{
|
||||
Secret = "zgoRtipbFcgQp0VGP8VZW8QhW4ll1swfvASqwr78",
|
||||
TokenValidityInMinutes = 1,
|
||||
};
|
||||
var jwt_service = new JwtGenerator(jwt_option);
|
||||
var token = jwt_service.generateAccessToken("new_earth", "caliverse");
|
||||
m_test_output_helper.WriteLine(token);
|
||||
Assert.NotNull(token);
|
||||
|
||||
var jwt_parser = new JwtParser(jwt_option);
|
||||
var token_parsed = jwt_parser.parseToken(token);
|
||||
Assert.NotNull(token_parsed);
|
||||
var sid = token_parsed.FindFirstValue(JwtRegisteredClaimNames.Sid);
|
||||
Assert.NotNull(sid);
|
||||
var typ = token_parsed.FindFirstValue(JwtRegisteredClaimNames.Typ);
|
||||
Assert.NotNull(typ);
|
||||
}
|
||||
}
|
||||
48
BrokerApiTest/Jwt/SSOTests.cs
Normal file
48
BrokerApiTest/Jwt/SSOTests.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
// using ServerCommon;
|
||||
// using ServerCore; using ServerBase;
|
||||
// using Services;
|
||||
//
|
||||
// namespace BrokerTest.Jwt;
|
||||
// public class SsoTests
|
||||
// {
|
||||
// private readonly ServerConfig m_server_config;
|
||||
// private readonly string m_web_portal_token_secret;
|
||||
// private readonly string m_account_db;
|
||||
//
|
||||
// public SsoTests()
|
||||
// {
|
||||
// Log.NLogFileName = "./TestConfig/nlog-BrokerApiServer.config";
|
||||
// Log.initLog("BrokerApiServerTest", "Developer");
|
||||
// var path = "./TestConfig/ServerConfig-Local.json";
|
||||
// var full_path = Path.GetFullPath(path);
|
||||
// m_server_config = new ServerConfig();
|
||||
// m_server_config.setConfigFilePath(full_path);
|
||||
// m_server_config.loadConfig();
|
||||
// m_account_db = m_server_config.AccountNftDb;
|
||||
// m_web_portal_token_secret = m_server_config.SsoAccountAuthJwtSecretKey;
|
||||
// }
|
||||
//
|
||||
// private async Task findTestAccount()
|
||||
// {
|
||||
// var sso_account_auth = new WebPortalTokenAuthService(m_account_db, m_web_portal_token_secret);
|
||||
// var result = await sso_account_auth.mysqlAuthWithEmail("tenafter71@gmail.com", 1);
|
||||
// Assert.True(result.isSuccess());
|
||||
// // m_account_id = result.getAccountId();
|
||||
// }
|
||||
//
|
||||
// [Fact]
|
||||
// public async Task ssoFailTest()
|
||||
// {
|
||||
// var sso_account_auth = new WebPortalTokenAuthService(m_account_db, m_web_portal_token_secret);
|
||||
// var result = await sso_account_auth.mysqlAuthWithEmail("test", 1);
|
||||
// Assert.True(result.isFail());
|
||||
// }
|
||||
//
|
||||
// [Fact]
|
||||
// public async Task ssoSuccessTest()
|
||||
// {
|
||||
// var sso_account_auth = new WebPortalTokenAuthService(m_account_db, m_web_portal_token_secret);
|
||||
// var result = await sso_account_auth.mysqlAuthWithEmail("test@test.com", 1);
|
||||
// Assert.True(result.isSuccess());
|
||||
// }
|
||||
// }
|
||||
Reference in New Issue
Block a user