Skip to content

Commit 9deef66

Browse files
committed
Merge pull request Azure#414 from yitao-zhang/dev
ADF cmdlet changes
2 parents 2811ed6 + f0009d0 commit 9deef66

File tree

8 files changed

+6611
-6505
lines changed

8 files changed

+6611
-6505
lines changed

src/ResourceManager/DataFactories/Commands.DataFactories.Test/UnitTests/NewDataFactoryEncryptValueTests.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public void TestOnPremDatasourceEncryptionSQLAuth()
3939
string linkedServiceType = "OnPremisesSqlLinkedService";
4040
string nonCredentialValue = "Driver=mydriver;server=myserver";
4141
string authenticationType = "Basic";
42+
string serverName = null;
43+
string databaseName = null;
4244

4345
var cmdlet = new NewAzureDataFactoryEncryptValueCommand
4446
{
@@ -50,17 +52,19 @@ public void TestOnPremDatasourceEncryptionSQLAuth()
5052
GatewayName = GatewayName,
5153
Type = linkedServiceType,
5254
NonCredentialValue = nonCredentialValue,
53-
AuthenticationType = authenticationType
55+
AuthenticationType = authenticationType,
56+
Server = serverName,
57+
Database = databaseName
5458
};
5559

5660
// Arrange
57-
this.dataFactoriesClientMock.Setup(f => f.OnPremisesEncryptString(secureString, ResourceGroupName, DataFactoryName, GatewayName, null, linkedServiceType, nonCredentialValue, authenticationType)).Returns(expectedOutput);
61+
this.dataFactoriesClientMock.Setup(f => f.OnPremisesEncryptString(secureString, ResourceGroupName, DataFactoryName, GatewayName, null, linkedServiceType, nonCredentialValue, authenticationType, serverName, databaseName)).Returns(expectedOutput);
5862

5963
// Action
6064
cmdlet.ExecuteCmdlet();
6165

6266
// Assert
63-
this.dataFactoriesClientMock.Verify(f => f.OnPremisesEncryptString(secureString, ResourceGroupName, DataFactoryName, GatewayName, null, linkedServiceType, nonCredentialValue, authenticationType), Times.Once());
67+
this.dataFactoriesClientMock.Verify(f => f.OnPremisesEncryptString(secureString, ResourceGroupName, DataFactoryName, GatewayName, null, linkedServiceType, nonCredentialValue, authenticationType, serverName, databaseName), Times.Once());
6468
this.commandRuntimeMock.Verify(f => f.WriteObject(expectedOutput), Times.Once());
6569
}
6670

@@ -76,6 +80,8 @@ public void TestOnPremDatasourceEncryptionWinAuth()
7680
string linkedServiceType = "OnPremisesFileSystemLinkedService";
7781
string nonCredentialValue = "Driver=mydriver;server=myserver";
7882
string authenticationType = "Basic";
83+
string serverName = null;
84+
string databaseName = null;
7985

8086
var cmdlet = new NewAzureDataFactoryEncryptValueCommand
8187
{
@@ -88,17 +94,19 @@ public void TestOnPremDatasourceEncryptionWinAuth()
8894
Credential = credential,
8995
Type = linkedServiceType,
9096
NonCredentialValue = nonCredentialValue,
91-
AuthenticationType = authenticationType
97+
AuthenticationType = authenticationType,
98+
Server = serverName,
99+
Database = databaseName
92100
};
93101

94102
// Arrange
95-
this.dataFactoriesClientMock.Setup(f => f.OnPremisesEncryptString(secureString, ResourceGroupName, DataFactoryName, GatewayName, credential, linkedServiceType, nonCredentialValue, authenticationType)).Returns(expectedOutput);
103+
this.dataFactoriesClientMock.Setup(f => f.OnPremisesEncryptString(secureString, ResourceGroupName, DataFactoryName, GatewayName, credential, linkedServiceType, nonCredentialValue, authenticationType, serverName, databaseName)).Returns(expectedOutput);
96104

97105
// Action
98106
cmdlet.ExecuteCmdlet();
99107

100108
// Assert
101-
this.dataFactoriesClientMock.Verify(f => f.OnPremisesEncryptString(secureString, ResourceGroupName, DataFactoryName, GatewayName, credential, linkedServiceType, nonCredentialValue, authenticationType), Times.Once());
109+
this.dataFactoriesClientMock.Verify(f => f.OnPremisesEncryptString(secureString, ResourceGroupName, DataFactoryName, GatewayName, credential, linkedServiceType, nonCredentialValue, authenticationType, serverName, databaseName), Times.Once());
102110
this.commandRuntimeMock.Verify(f => f.WriteObject(expectedOutput), Times.Once());
103111
}
104112
}

src/ResourceManager/DataFactories/Commands.DataFactories/Commands.DataFactories.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@
7373
<HintPath>..\..\..\packages\Microsoft.DataFactories.Runtime.0.11.1-preview\lib\net45\Microsoft.DataFactories.Runtime.dll</HintPath>
7474
</Reference>
7575
<Reference Include="Microsoft.DataTransfer.Gateway.Encryption">
76-
<HintPath>..\..\..\packages\Microsoft.DataTransfer.Gateway.Encryption.1.4.0-preview\lib\net45\Microsoft.DataTransfer.Gateway.Encryption.dll</HintPath>
76+
<HintPath>..\..\..\packages\Microsoft.DataTransfer.Gateway.Encryption.1.5.0-preview\lib\net45\Microsoft.DataTransfer.Gateway.Encryption.dll</HintPath>
77+
<Private>True</Private>
7778
</Reference>
7879
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory">
7980
<SpecificVersion>False</SpecificVersion>

src/ResourceManager/DataFactories/Commands.DataFactories/DataFactoryBaseCmdlet.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ internal DataFactoryClient DataFactoryClient
4040
{
4141
if (this.dataFactoryClient == null)
4242
{
43-
this.dataFactoryClient = new DataFactoryClient(Profile.Context);
43+
this.dataFactoryClient = new DataFactoryClient(Profile);
4444
}
4545
return this.dataFactoryClient;
4646
}

src/ResourceManager/DataFactories/Commands.DataFactories/Encrypt/NewAzureDataFactoryEncryptValueCommand.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,14 @@ public class NewAzureDataFactoryEncryptValueCommand : DataFactoryBaseCmdlet
4646
[Parameter(ParameterSetName = ByFactoryName, Position = 4, Mandatory = false, HelpMessage = "The windows authentication credential.")]
4747
public PSCredential Credential { get; set; }
4848

49-
[Parameter(ParameterSetName = ByFactoryObject, Position = 4, Mandatory = false, HelpMessage = "The linked service type.")]
50-
[Parameter(ParameterSetName = ByFactoryName, Position = 5, Mandatory = false, HelpMessage = "The linked service type.")]
51-
[ValidateSet("OnPremisesSqlLinkedService", "OnPremisesFileSystemLinkedService", "OnPremisesOracleLinkedService", "OnPremisesOdbcLinkedService", IgnoreCase = true)]
49+
[Parameter(ParameterSetName = ByFactoryObject, Position = 4, Mandatory = false,
50+
HelpMessage = "The linked service type.")]
51+
[Parameter(ParameterSetName = ByFactoryName, Position = 5, Mandatory = false,
52+
HelpMessage = "The linked service type.")]
53+
[ValidateSet("OnPremisesSqlLinkedService", "OnPremisesFileSystemLinkedService", "OnPremisesOracleLinkedService",
54+
"OnPremisesOdbcLinkedService", "OnPremisesPostgreSqlLinkedService", "OnPremisesTeradataLinkedService",
55+
"OnPremisesMySQLLinkedService", "OnPremisesDB2LinkedService", "OnPremisesSybaseLinkedService",
56+
IgnoreCase = true)]
5257
public string Type { get; set; }
5358

5459
[Parameter(ParameterSetName = ByFactoryObject, Position = 5, Mandatory = false, HelpMessage = "The non-credential value.")]
@@ -60,6 +65,14 @@ public class NewAzureDataFactoryEncryptValueCommand : DataFactoryBaseCmdlet
6065
[ValidateSet("Windows", "Basic", "Anonymous", IgnoreCase = true)]
6166
public string AuthenticationType { get; set; }
6267

68+
[Parameter(ParameterSetName = ByFactoryObject, Position = 7, Mandatory = false, HelpMessage = "The server name.")]
69+
[Parameter(ParameterSetName = ByFactoryName, Position = 8, Mandatory = false, HelpMessage = "The server name.")]
70+
public string Server { get; set; }
71+
72+
[Parameter(ParameterSetName = ByFactoryObject, Position = 8, Mandatory = false, HelpMessage = "The database name.")]
73+
[Parameter(ParameterSetName = ByFactoryName, Position = 9, Mandatory = false, HelpMessage = "The database name.")]
74+
public string Database { get; set; }
75+
6376
[EnvironmentPermission(SecurityAction.Demand, Unrestricted = true)]
6477
public override void ExecuteCmdlet()
6578
{
@@ -85,7 +98,8 @@ public override void ExecuteCmdlet()
8598
else
8699
{
87100
// On-premises encryption with Gateway
88-
encryptedValue = DataFactoryClient.OnPremisesEncryptString(Value, ResourceGroupName, DataFactoryName, GatewayName, Credential, Type, NonCredentialValue, AuthenticationType);
101+
encryptedValue = DataFactoryClient.OnPremisesEncryptString(Value, ResourceGroupName, DataFactoryName,
102+
GatewayName, Credential, Type, NonCredentialValue, AuthenticationType, Server, Database);
89103
}
90104

91105
WriteObject(encryptedValue);

0 commit comments

Comments
 (0)