From 070e6a7d05117f4f5cd145ad7778f5a5b8db537e Mon Sep 17 00:00:00 2001 From: stevelee Date: Tue, 26 Apr 2022 15:42:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E8=BF=9C=E7=A8=8B=E6=8E=88?= =?UTF-8?q?=E6=9D=83=E8=AE=BF=E9=97=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BPA.SaaS.Stock.Api.Bootstrap.csproj | 4 ++-- .../BPA.SaaS.Stock.Api.SDK.csproj | 1 - .../BPA.SaaS.Stock.Api.Service.csproj | 2 +- .../AuthBasicToken.cs | 19 +++++++++++++--- .../BPA.SaaS.Stock.Api.UnitTest.csproj | 1 - .../Products/ProductCodeServiceTests.cs | 22 ++++++++++++++++++- 6 files changed, 40 insertions(+), 9 deletions(-) diff --git a/src/BPA.SaaS.Stock.Api.Bootstrap/BPA.SaaS.Stock.Api.Bootstrap.csproj b/src/BPA.SaaS.Stock.Api.Bootstrap/BPA.SaaS.Stock.Api.Bootstrap.csproj index f60b6d8..149b88c 100644 --- a/src/BPA.SaaS.Stock.Api.Bootstrap/BPA.SaaS.Stock.Api.Bootstrap.csproj +++ b/src/BPA.SaaS.Stock.Api.Bootstrap/BPA.SaaS.Stock.Api.Bootstrap.csproj @@ -7,14 +7,14 @@ - + - + diff --git a/src/BPA.SaaS.Stock.Api.SDK/BPA.SaaS.Stock.Api.SDK.csproj b/src/BPA.SaaS.Stock.Api.SDK/BPA.SaaS.Stock.Api.SDK.csproj index f2da8bf..ae362e7 100644 --- a/src/BPA.SaaS.Stock.Api.SDK/BPA.SaaS.Stock.Api.SDK.csproj +++ b/src/BPA.SaaS.Stock.Api.SDK/BPA.SaaS.Stock.Api.SDK.csproj @@ -8,7 +8,6 @@ - diff --git a/src/BPA.SaaS.Stock.Api.Service/BPA.SaaS.Stock.Api.Service.csproj b/src/BPA.SaaS.Stock.Api.Service/BPA.SaaS.Stock.Api.Service.csproj index 48a94a5..2d4cb1c 100644 --- a/src/BPA.SaaS.Stock.Api.Service/BPA.SaaS.Stock.Api.Service.csproj +++ b/src/BPA.SaaS.Stock.Api.Service/BPA.SaaS.Stock.Api.Service.csproj @@ -9,7 +9,7 @@ - + diff --git a/src/BPA.SaaS.Stock.Api.UnitTest/AuthBasicToken.cs b/src/BPA.SaaS.Stock.Api.UnitTest/AuthBasicToken.cs index ff1d498..065e730 100644 --- a/src/BPA.SaaS.Stock.Api.UnitTest/AuthBasicToken.cs +++ b/src/BPA.SaaS.Stock.Api.UnitTest/AuthBasicToken.cs @@ -18,11 +18,10 @@ public class AuthBasicToken : BaseUnitTest { var result = await _basicWebApiSDK.AuthServiceApi.LoginAsync(EnumLoginType.FranchiseeUsers, new LoginInput { - Account = userName, + Account = userName, Password = password, Name = "", - RoleId = "", - + RoleId = "" }); if (!result.IsOK) throw new Exception("登录失败"); @@ -38,4 +37,18 @@ public class AuthBasicToken : BaseUnitTest OrgId = jsonToken.Claims.FirstOrDefault(f => f.Type == "OrgId")?.Value }; } + + public async Task GetToken(string userName, string password) + { + var result = await _basicWebApiSDK.AuthServiceApi.LoginAsync(EnumLoginType.FranchiseeUsers, new LoginInput + { + Account = userName, + Password = password, + Name = "", + RoleId = "" + }); + if (!result.IsOK) throw new Exception("登录失败"); + + return result.Data.token.ToBearer(); + } } \ No newline at end of file diff --git a/src/BPA.SaaS.Stock.Api.UnitTest/BPA.SaaS.Stock.Api.UnitTest.csproj b/src/BPA.SaaS.Stock.Api.UnitTest/BPA.SaaS.Stock.Api.UnitTest.csproj index be441ad..4ada4f5 100644 --- a/src/BPA.SaaS.Stock.Api.UnitTest/BPA.SaaS.Stock.Api.UnitTest.csproj +++ b/src/BPA.SaaS.Stock.Api.UnitTest/BPA.SaaS.Stock.Api.UnitTest.csproj @@ -6,7 +6,6 @@ - diff --git a/src/BPA.SaaS.Stock.Api.UnitTest/Products/ProductCodeServiceTests.cs b/src/BPA.SaaS.Stock.Api.UnitTest/Products/ProductCodeServiceTests.cs index ff55198..d367229 100644 --- a/src/BPA.SaaS.Stock.Api.UnitTest/Products/ProductCodeServiceTests.cs +++ b/src/BPA.SaaS.Stock.Api.UnitTest/Products/ProductCodeServiceTests.cs @@ -1,4 +1,6 @@ using BPA.Component.WebApiExtensions; +using BPA.SaaS.Basic.Api.DTO.InnerEnum; +using BPA.SaaS.Basic.Api.SDK; using BPA.SaaS.Stock.Api.DTO; using BPA.SaaS.Stock.Api.IService.Product; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -10,20 +12,38 @@ public class ProductCodeServiceTests : BaseUnitTest { private readonly IProductCodeService _productCode; private readonly AuthBasicToken _authBasicToken; + private readonly BasicWebApiSDK _basicWebApiSDK; public ProductCodeServiceTests() { _productCode = GetService(); _authBasicToken = GetService(); + _basicWebApiSDK = GetService(); } [TestMethod] - public void TestRemoteAuthToken() + public void TestRemoteGetAuthToken() { var claimInfo = _authBasicToken.GetClaimInfo("admin", "admin").Result; // 远程获取登录凭证 Assert.IsTrue(claimInfo != null); } + [TestMethod] + public void TestRemoteGetUserInfo() + { + var token = _authBasicToken.GetToken("admin", "admin").Result; + var result = _basicWebApiSDK.AuthServiceApi.GetLoginUserAsync(EnumLoginType.FranchiseeUsers, token).Result; + Assert.IsTrue(result.IsOK); + } + + [TestMethod] + public void TestRemoteLoginOut() + { + var token = _authBasicToken.GetToken("admin", "admin").Result; + var result = _basicWebApiSDK.AuthServiceApi.LogoutAsync(token).Result; + Assert.IsTrue(result.IsOK); + } + [TestMethod] public void TestGetProductList() {