-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add data masking client, test, recording #3391
Conversation
Corresponding swagger pull request: Azure/azure-rest-api-specs#1321 Should be merged soon, is only blocked because the reviewer assigned is OOF. |
@@ -40,6 +40,10 @@ public class SqlManagementTestUtilities | |||
|
|||
public const string DefaultEuapPrimaryLocation = "East US 2 EUAP"; | |||
|
|||
public const string DefaultLogin = "dummylogin"; | |||
|
|||
public const string DefaultPassword = "Un53cuRE!"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we generate it in runtime with some random seed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, because this affects how test recordings and playback works, changing this would mean changing every single scenario test and re-recording them again, so it's not trivial.
EDIT: Created issue #3405 to track this.
[Fact] | ||
public void TestCreateUpdateGetDataMaskingRules() | ||
{ | ||
string testPrefix = "sqlcrudtest-"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add data masking string to the test prefix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay.
@@ -5,7 +5,7 @@ | |||
|
|||
@echo off | |||
if "%1" == "" ( | |||
set specFile="https://raw.githubusercontent.com/Azure/azure-rest-api-specs/9346f0adc0caddbfa33dbe69a469c199705cf38a/arm-sql/compositeSql.json" | |||
set specFile="https://raw.githubusercontent.com/Azure/azure-rest-api-specs/03ff383aac77901093d96c049e248d2c7a3cf4ff/arm-sql/compositeSql.json" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ask from the .net SDK team to know what version of compositeSql.json is used to generate client
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's SDK Generation Guidelines number 2 :)
@@ -27,4 +27,32 @@ public enum TransparentDataEncryptionStatus | |||
[EnumMember(Value = "Disabled")] | |||
Disabled | |||
} | |||
internal static class TransparentDataEncryptionStatusEnumExtension |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how is this change related?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generated client from latest swagger
case "Enabled": | ||
return SecurityAlertPolicyUseServerDefault.Enabled; | ||
case "Disabled": | ||
return SecurityAlertPolicyUseServerDefault.Disabled; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the "}" should be in a new line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filed Azure/autorest#2386 against autorest code generator to fix this
case "Enabled": | ||
return SecurityAlertPolicyState.Enabled; | ||
case "Disabled": | ||
return SecurityAlertPolicyState.Disabled; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the "}" should be in a new line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is generated code and changing the formatting would just be overwritten the next time someone generates client
public DataMaskingRuleState? RuleState { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the schema name on which the data masking rule is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can the comment be in one line? (here and below)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is generated code and changing the formatting would just be overwritten the next time someone generates client
/// </exception> | ||
public virtual void Validate() | ||
{ | ||
if (SchemaName == null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data masking function should not be null too...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will need a re-generation which will need swagger update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Data masking function is stored here as a non-nullable enum
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, just minor comments
{ | ||
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder() | ||
{ | ||
DataSource = string.Format("{0}.database.windows.net", server.Name), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is server.FullyQualifiedDomainName
that you can use
{ | ||
DataSource = string.Format("{0}.database.windows.net", server.Name), | ||
UserID = SqlManagementTestUtilities.DefaultLogin, | ||
Password = SqlManagementTestUtilities.DefaultPassword, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice change, can you also update ImportExport tests to use these?
// Create test table with columns | ||
HttpRecorderMode testMode = HttpMockServer.GetCurrentMode(); | ||
|
||
if (testMode != HttpRecorderMode.Playback) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add comment explaining why it's not needed in Playback, i.e. because there is no HTTP requests in this block and it requires the server to really exist
{ | ||
string testPrefix = "sqlcrudtest-"; | ||
string suiteName = this.GetType().FullName; | ||
SqlManagementTestUtilities.RunTestInNewV12Server(suiteName, "TestCreateUpdateGetDataMaskingRules", testPrefix, (resClient, sqlClient, resourceGroup, server) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use new SqlManagementTestContext instead? See Restore LTR test for example
public void TestCreateUpdateGetDataMaskingRules() | ||
{ | ||
string testPrefix = "sqldatamaskingcrudtest-"; | ||
string suiteName = this.GetType().FullName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suiteName
unused?
/// </exception> | ||
public virtual void Validate() | ||
{ | ||
if (SchemaName == null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will need a re-generation which will need swagger update
@shahabhijeet Thanks, abhijeet! |
Description
Add generated client, test and recording for Data Masking APIs.
TODO: need to update AssemblyInfo.cs because we already have 2 SQL SDK pull requests open that haven't been reviewed yet, so need to determine the version based on which ones merge first.
Azure/azure-rest-api-specs#1321
This checklist is used to make sure that common guidelines for a pull request are followed.
General Guidelines
Testing Guidelines
SDK Generation Guidelines
*.csproj
andAssemblyInfo.cs
files have been updated with the new version of the SDK.