Skip to content
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

Merged
merged 5 commits into from
Jun 23, 2017
Merged

Conversation

nathannfan
Copy link
Contributor

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

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

SDK Generation Guidelines

  • If an SDK is being regenerated based on a new swagger spec, a link to the pull request containing these swagger spec changes has been included above.
  • The generate.cmd file for the SDK has been updated with the version of AutoRest, as well as the commitid of your swagger spec or link to the swagger spec, used to generate the code.
  • The *.csproj and AssemblyInfo.cs files have been updated with the new version of the SDK.

@nathannfan
Copy link
Contributor Author

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!";
Copy link
Member

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?

Copy link
Contributor Author

@nathannfan nathannfan Jun 22, 2017

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-";
Copy link
Member

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

Copy link
Contributor Author

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"
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Contributor

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
Copy link
Member

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?

Copy link
Contributor Author

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; }
Copy link
Member

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

Copy link
Contributor

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; }
Copy link
Member

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

Copy link
Contributor Author

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
Copy link
Member

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)

Copy link
Contributor Author

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)
Copy link
Member

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...

Copy link
Member

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

Copy link
Contributor Author

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

Copy link
Contributor

@jaredmoo jaredmoo left a 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),
Copy link
Contributor

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,
Copy link
Contributor

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)
Copy link
Contributor

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) =>
Copy link
Contributor

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;
Copy link
Contributor

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)
Copy link
Member

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 shahabhijeet merged commit d6c9636 into Azure:psSdkJson6 Jun 23, 2017
@nathannfan
Copy link
Contributor Author

@shahabhijeet Thanks, abhijeet!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants