Skip to content

Commit

Permalink
Merge branch 'refs/heads/master' into feat/#364
Browse files Browse the repository at this point in the history
# Conflicts:
#	Casbin.UnitTests/GenericTests/GenericFunctionTest.cs
  • Loading branch information
Taoyuesong committed Oct 29, 2024
2 parents 91f56ab + 85b9330 commit bdaf9cf
Show file tree
Hide file tree
Showing 117 changed files with 1,984 additions and 2,277 deletions.
21 changes: 13 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup .NET SDK
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
3.1.x
Expand Down Expand Up @@ -70,7 +70,7 @@ jobs:
- name: Upload test results artefacts
if: github.repository_owner == 'casbin' && github.event_name == 'push'
uses: actions/upload-artifact@v1.0.0
uses: actions/upload-artifact@v4
with:
name: "drop-ci-test-results"
path: './test-results'
Expand All @@ -82,12 +82,17 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Dry run semantic-release
run: |
export PATH=$PATH:$(yarn global bin)
yarn global add semantic-release@17.4.3
yarn global add semantic-release@24.1.1
semantic-release --dry-run
release-build-version:
Expand All @@ -97,7 +102,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -108,7 +113,7 @@ jobs:
run: git tag -l -n

- name: Setup .NET SDK
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
3.1.x
Expand Down Expand Up @@ -147,7 +152,7 @@ jobs:
}
- name: Upload packages artefacts
uses: actions/upload-artifact@v1.0.0
uses: actions/upload-artifact@v4
with:
name: "drop-ci-build-packages"
path: './packages'
14 changes: 7 additions & 7 deletions .github/workflows/infersharp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup .NET SDK
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
3.1.x
Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:
run: cat infer-out/report.txt

- name: Upload net8.0 infer# results artefacts
uses: actions/upload-artifact@v1.0.0
uses: actions/upload-artifact@v4
with:
name: "infersharp-net8.0-results"
path: './infer-out/report.txt'
Expand All @@ -57,7 +57,7 @@ jobs:
run: cat infer-out/report.txt

- name: Upload net7.0 infer# results artefacts
uses: actions/upload-artifact@v1.0.0
uses: actions/upload-artifact@v4
with:
name: "infersharp-net7.0-results"
path: './infer-out/report.txt'
Expand All @@ -71,7 +71,7 @@ jobs:
run: cat infer-out/report.txt

- name: Upload net6.0 infer# results artefacts
uses: actions/upload-artifact@v1.0.0
uses: actions/upload-artifact@v4
with:
name: "infersharp-net6.0-results"
path: './infer-out/report.txt'
Expand All @@ -85,7 +85,7 @@ jobs:
run: cat infer-out/report.txt

- name: Upload net5.0 infer# results artefacts
uses: actions/upload-artifact@v1.0.0
uses: actions/upload-artifact@v4
with:
name: "infersharp-net5.0-results"
path: './infer-out/report.txt'
Expand All @@ -99,7 +99,7 @@ jobs:
run: cat infer-out/report.txt

- name: Upload net3.1 infer# results artefacts
uses: actions/upload-artifact@v1.0.0
uses: actions/upload-artifact@v4
with:
name: "infersharp-net3.1-results"
path: './infer-out/report.txt'
21 changes: 13 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup .NET SDK
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
3.1.x
Expand Down Expand Up @@ -75,7 +75,7 @@ jobs:
}
- name: Upload test results artefacts
uses: actions/upload-artifact@v1.0.0
uses: actions/upload-artifact@v4
with:
name: "drop-ci-test-results"
path: './test-results'
Expand All @@ -87,12 +87,17 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Run semantic-release
run: |
export PATH=$PATH:$(yarn global bin)
yarn global add semantic-release@19.0.2
yarn global add semantic-release@24.1.1
semantic-release
push-packages:
Expand All @@ -102,7 +107,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -113,7 +118,7 @@ jobs:
run: git tag -l -n

- name: Setup .NET SDK
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
3.1.x
Expand Down Expand Up @@ -148,7 +153,7 @@ jobs:
}
- name: Upload packages artefacts
uses: actions/upload-artifact@v1.0.0
uses: actions/upload-artifact@v4
with:
name: "drop-ci-packages"
path: './packages'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/semantic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: windows-latest
steps:
- name: semantic-pull-request
uses: amannn/action-semantic-pull-request@v4
uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
2 changes: 1 addition & 1 deletion Casbin.Benchmark/TestHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public static class TestHelper
{
public static string GetTestFilePath(string fileName)
{
return Path.Combine("examples", fileName);
return Path.Combine("Examples", fileName);
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions Casbin.UnitTests/GenericTests/GenericFunctionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public void TestGenericFunction()
Assert.False(func1(Request.CreateValues("B", 1), Policy.CreateValues("B", 2)));
}

#if !NET452
[Fact]
public void TestGenericFunctionModel()
{
Expand Down Expand Up @@ -63,5 +64,6 @@ public void TestGenericFunctionModel()
Assert.False(e.Enforce(1, 2));
Assert.True(e.Enforce("1", "111"));
}
#endif

}
46 changes: 21 additions & 25 deletions Casbin.UnitTests/GenericTests/SupportCountTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,85 +37,81 @@ private static void TestEnforce(IEnforcer enforcer, EnforceContext context, int
{
case 1:
Assert.True(enforcer.Enforce(context, "value1"));
Assert.True(enforcer.Enforce(context, new[] { "value1" }));
Assert.True(enforcer.Enforce(context, ["value1"]));
break;
case 2:
Assert.True(enforcer.Enforce(context, "value1", "value2"));
Assert.True(enforcer.Enforce(context, new[] { "value1", "value2" }));
Assert.True(enforcer.Enforce(context, ["value1", "value2"]));
break;
case 3:
Assert.True(enforcer.Enforce(context, "value1", "value2", "value3"));
Assert.True(enforcer.Enforce(context, new[] { "value1", "value2", "value3" }));
Assert.True(enforcer.Enforce(context, ["value1", "value2", "value3"]));
break;
case 4:
Assert.True(enforcer.Enforce(context, "value1", "value2", "value3",
"value4"));
Assert.True(enforcer.Enforce(context, new[] { "value1", "value2", "value3", "value4" }));
Assert.True(enforcer.Enforce(context, ["value1", "value2", "value3", "value4"]));
break;
case 5:
Assert.True(enforcer.Enforce(context, "value1", "value2", "value3",
"value4", "value5"));
Assert.True(enforcer.Enforce(context, new[] { "value1", "value2", "value3", "value4", "value5" }));
Assert.True(enforcer.Enforce(context, ["value1", "value2", "value3", "value4", "value5"]));
break;
case 6:
Assert.True(enforcer.Enforce(context, "value1", "value2", "value3",
"value4", "value5", "value6"));
Assert.True(enforcer.Enforce(context,
new[] { "value1", "value2", "value3", "value4", "value5", "value6" }));
["value1", "value2", "value3", "value4", "value5", "value6"]));
break;
case 7:
Assert.True(enforcer.Enforce(context, "value1", "value2", "value3",
"value4", "value5", "value6", "value7"));
Assert.True(enforcer.Enforce(context,
new[] { "value1", "value2", "value3", "value4", "value5", "value6", "value7" }));
["value1", "value2", "value3", "value4", "value5", "value6", "value7"]));
break;
case 8:
Assert.True(enforcer.Enforce(context, "value1", "value2", "value3",
"value4", "value5", "value6", "value7", "value8"));
Assert.True(enforcer.Enforce(context,
new[] { "value1", "value2", "value3", "value4", "value5", "value6", "value7", "value8" }));
["value1", "value2", "value3", "value4", "value5", "value6", "value7", "value8"]));
break;
case 9:
Assert.True(enforcer.Enforce(context, "value1", "value2", "value3",
"value4", "value5", "value6", "value7", "value8", "value9"));
Assert.True(enforcer.Enforce(context,
new[]
{
"value1", "value2", "value3", "value4", "value5", "value6", "value7", "value8", "value9"
}));
[
"value1", "value2", "value3", "value4", "value5", "value6", "value7", "value8", "value9"
]));
break;
case 10:
Assert.True(enforcer.Enforce(context, "value1", "value2", "value3",
"value4", "value5", "value6", "value7", "value8", "value9",
"value10"));
Assert.True(enforcer.Enforce(context,
new[]
{
"value1", "value2", "value3", "value4", "value5", "value6", "value7", "value8", "value9",
[
"value1", "value2", "value3", "value4", "value5", "value6", "value7", "value8", "value9",
"value10"
}));
]));
break;
case 11:
Assert.True(enforcer.Enforce(context, "value1", "value2", "value3",
"value4", "value5", "value6", "value7", "value8", "value9",
"value10", "value11"));
Assert.True(enforcer.Enforce(context,
new[]
{
"value1", "value2", "value3", "value4", "value5", "value6", "value7", "value8", "value9",
[
"value1", "value2", "value3", "value4", "value5", "value6", "value7", "value8", "value9",
"value10", "value11"
}));
]));
break;
case 12:
Assert.True(enforcer.Enforce(context, "value1", "value2", "value3",
"value4", "value5", "value6", "value7", "value8", "value9",
"value10", "value11", "value12"));
Assert.True(enforcer.Enforce(context,
new[]
{
"value1", "value2", "value3", "value4", "value5", "value6", "value7", "value8", "value9",
[
"value1", "value2", "value3", "value4", "value5", "value6", "value7", "value8", "value9",
"value10", "value11", "value12"
}));
]));
break;
case 13:
Assert.True(enforcer.Enforce(context, Request.CreateValues("value1", "value2", "value3",
Expand All @@ -131,7 +127,7 @@ private static void TestEnforce(IEnforcer enforcer, EnforceContext context, int

private static IPolicyValues CreateTestPolicy(int count)
{
List<string> policy = new();
List<string> policy = [];
for (int i = 0; i < count; i++)
{
policy.Add($"value{i + 1}");
Expand Down
2 changes: 1 addition & 1 deletion Casbin.UnitTests/Mock/MockRoleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class MockCustomRoleManager : IRoleManager

public IEnumerable<string> GetRoles(string name, string domain = null) => null;
public IEnumerable<string> GetUsers(string name, string domain = null) => null;
public IEnumerable<string> GetDomains(string name) => Enumerable.Empty<string>();
public IEnumerable<string> GetDomains(string name) => [];

public bool HasLink(string name1, string name2, string domain = null)
{
Expand Down
14 changes: 14 additions & 0 deletions Casbin.UnitTests/Mock/TestRescource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace Casbin.UnitTests.Mock;

public class TestResource
{
public TestResource(string name, string owner)
{
Name = name;
Owner = owner;
}

public string Name { get; }

public string Owner { get; }
}
14 changes: 14 additions & 0 deletions Casbin.UnitTests/Mock/TestSubject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace Casbin.UnitTests.Mock;

public class TestSubject
{
public TestSubject(string name, int age)
{
Name = name;
Age = age;
}

public string Name { get; }

public int Age { get; }
}
Loading

0 comments on commit bdaf9cf

Please sign in to comment.