Kaynağa Gözat

完成远程授权访问

master
stevelee 2 yıl önce
ebeveyn
işleme
070e6a7d05
6 değiştirilmiş dosya ile 40 ekleme ve 9 silme
  1. +2
    -2
      src/BPA.SaaS.Stock.Api.Bootstrap/BPA.SaaS.Stock.Api.Bootstrap.csproj
  2. +0
    -1
      src/BPA.SaaS.Stock.Api.SDK/BPA.SaaS.Stock.Api.SDK.csproj
  3. +1
    -1
      src/BPA.SaaS.Stock.Api.Service/BPA.SaaS.Stock.Api.Service.csproj
  4. +16
    -3
      src/BPA.SaaS.Stock.Api.UnitTest/AuthBasicToken.cs
  5. +0
    -1
      src/BPA.SaaS.Stock.Api.UnitTest/BPA.SaaS.Stock.Api.UnitTest.csproj
  6. +21
    -1
      src/BPA.SaaS.Stock.Api.UnitTest/Products/ProductCodeServiceTests.cs

+ 2
- 2
src/BPA.SaaS.Stock.Api.Bootstrap/BPA.SaaS.Stock.Api.Bootstrap.csproj Dosyayı Görüntüle

@@ -7,14 +7,14 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="BPA.SaaS.Basic.Api.SDK" Version="1.0.1" />
<PackageReference Include="BPA.SaaS.Basic.Api.SDK" Version="1.0.8" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.2.3" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.2.3" />
<PackageReference Include="BPA.Component.CAP.RabbitMQ" Version="1.0.2" />
<PackageReference Include="BPA.Component.DTOCommon" Version="1.0.9" />
<PackageReference Include="BPA.Component.Extensions" Version="1.0.4" />
<PackageReference Include="BPA.Component.WebApiExtensions" Version="1.0.17" />
<PackageReference Include="BPA.Component.WebApiExtensions" Version="1.0.20" />
<ProjectReference Include="..\BPA.SaaS.Stock.Api.DTO\BPA.SaaS.Stock.Api.DTO.csproj" />
<ProjectReference Include="..\BPA.SaaS.Stock.Api.Model\BPA.SaaS.Stock.Api.Model.csproj" />


+ 0
- 1
src/BPA.SaaS.Stock.Api.SDK/BPA.SaaS.Stock.Api.SDK.csproj Dosyayı Görüntüle

@@ -8,7 +8,6 @@
<PackageReleaseNotes />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BPA.SaaS.Basic.Api.SDK" Version="1.0.1" />
<PackageReference Include="BPA.SaaS.Stock.Api.DTO" Version="1.0.2" />
<PackageReference Include="BPA.Component.DTOCommon" Version="1.0.9" />
<PackageReference Include="BPA.Component.SDKCommon" Version="1.0.3" />


+ 1
- 1
src/BPA.SaaS.Stock.Api.Service/BPA.SaaS.Stock.Api.Service.csproj Dosyayı Görüntüle

@@ -9,7 +9,7 @@
<PackageReference Include="BPA.Component.DTOCommon" Version="1.0.9" />
<PackageReference Include="BPA.Component.Extensions" Version="1.0.4" />
<PackageReference Include="BPA.Component.SDKCommon" Version="1.0.3" />
<PackageReference Include="BPA.Component.WebApiExtensions" Version="1.0.17" />
<PackageReference Include="BPA.Component.WebApiExtensions" Version="1.0.20" />
<ProjectReference Include="..\BPA.SaaS.Stock.Api.DTO\BPA.SaaS.Stock.Api.DTO.csproj" />
<ProjectReference Include="..\BPA.SaaS.Stock.Api.Model\BPA.SaaS.Stock.Api.Model.csproj" />


+ 16
- 3
src/BPA.SaaS.Stock.Api.UnitTest/AuthBasicToken.cs Dosyayı Görüntüle

@@ -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<string> 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();
}
}

+ 0
- 1
src/BPA.SaaS.Stock.Api.UnitTest/BPA.SaaS.Stock.Api.UnitTest.csproj Dosyayı Görüntüle

@@ -6,7 +6,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BPA.SaaS.Basic.Api.SDK" Version="1.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.9" />


+ 21
- 1
src/BPA.SaaS.Stock.Api.UnitTest/Products/ProductCodeServiceTests.cs Dosyayı Görüntüle

@@ -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<IProductCodeService>();
_authBasicToken = GetService<AuthBasicToken>();
_basicWebApiSDK = GetService<BasicWebApiSDK>();
}

[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()
{


Yükleniyor…
İptal
Kaydet