-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
code/DeltaKustoLib/CommandModel/Policies/DeleteRowLevelSecurityPolicyCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using Kusto.Language.Syntax; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.Immutable; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Text.Json; | ||
using System.Threading.Tasks; | ||
|
||
namespace DeltaKustoLib.CommandModel.Policies | ||
{ | ||
/// <summary> | ||
/// Models ??? (unexisting documentation) | ||
/// </summary> | ||
[Command(20000, "Delete Row Level Security Policies")] | ||
public class DeleteRowLevelSecurityPolicyCommand : TableOnlyPolicyCommandBase | ||
{ | ||
public override string CommandFriendlyName => ".delete <entity> policy row_level_security"; | ||
|
||
public override string ScriptPath => "tables/policies/row_level_security/delete"; | ||
|
||
public DeleteRowLevelSecurityPolicyCommand(EntityName tableName) | ||
: base(tableName) | ||
{ | ||
} | ||
|
||
internal static CommandBase FromCode(SyntaxElement rootElement) | ||
{ | ||
var tableName = rootElement.GetFirstDescendant<NameReference>(); | ||
|
||
return new DeleteRowLevelSecurityPolicyCommand(EntityName.FromCode(tableName.Name)); | ||
} | ||
|
||
public override string ToScript(ScriptingContext? context) | ||
{ | ||
var builder = new StringBuilder(); | ||
|
||
builder.Append(".delete table "); | ||
builder.Append(TableName.ToScript()); | ||
builder.Append(" policy row_level_security"); | ||
|
||
return builder.ToString(); | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
code/DeltaKustoUnitTest/CommandParsing/Policies/DeleteRowLevelSecurityPolicyTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using DeltaKustoLib.CommandModel; | ||
using DeltaKustoLib.CommandModel.Policies; | ||
using System; | ||
using System.Linq; | ||
using System.Text.Json; | ||
using Xunit; | ||
|
||
namespace DeltaKustoUnitTest.CommandParsing.Policies | ||
{ | ||
public class DeleteRowLevelSecurityPolicyTest : ParsingTestBase | ||
{ | ||
[Fact] | ||
public void SimpleTable() | ||
{ | ||
TestAutoDeletePolicy("A"); | ||
} | ||
|
||
[Fact] | ||
public void FunkyTable() | ||
{ | ||
TestAutoDeletePolicy("A- 1"); | ||
} | ||
|
||
private void TestAutoDeletePolicy(string tableName) | ||
{ | ||
var commandText = new DeleteRowLevelSecurityPolicyCommand(new EntityName(tableName)) | ||
.ToScript(null); | ||
var command = ParseOneCommand(commandText); | ||
|
||
Assert.IsType<DeleteRowLevelSecurityPolicyCommand>(command); | ||
} | ||
} | ||
} |