Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public void TestOnPremDatasourceEncryptionSQLAuth()
string linkedServiceType = "OnPremisesSqlLinkedService";
string nonCredentialValue = "Driver=mydriver;server=myserver";
string authenticationType = "Basic";
string serverName = null;
string databaseName = null;

var cmdlet = new NewAzureDataFactoryEncryptValueCommand
{
Expand All @@ -50,17 +52,19 @@ public void TestOnPremDatasourceEncryptionSQLAuth()
GatewayName = GatewayName,
Type = linkedServiceType,
NonCredentialValue = nonCredentialValue,
AuthenticationType = authenticationType
AuthenticationType = authenticationType,
Server = serverName,
Database = databaseName
};

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

// Action
cmdlet.ExecuteCmdlet();

// Assert
this.dataFactoriesClientMock.Verify(f => f.OnPremisesEncryptString(secureString, ResourceGroupName, DataFactoryName, GatewayName, null, linkedServiceType, nonCredentialValue, authenticationType), Times.Once());
this.dataFactoriesClientMock.Verify(f => f.OnPremisesEncryptString(secureString, ResourceGroupName, DataFactoryName, GatewayName, null, linkedServiceType, nonCredentialValue, authenticationType, serverName, databaseName), Times.Once());
this.commandRuntimeMock.Verify(f => f.WriteObject(expectedOutput), Times.Once());
}

Expand All @@ -76,6 +80,8 @@ public void TestOnPremDatasourceEncryptionWinAuth()
string linkedServiceType = "OnPremisesFileSystemLinkedService";
string nonCredentialValue = "Driver=mydriver;server=myserver";
string authenticationType = "Basic";
string serverName = null;
string databaseName = null;

var cmdlet = new NewAzureDataFactoryEncryptValueCommand
{
Expand All @@ -88,17 +94,19 @@ public void TestOnPremDatasourceEncryptionWinAuth()
Credential = credential,
Type = linkedServiceType,
NonCredentialValue = nonCredentialValue,
AuthenticationType = authenticationType
AuthenticationType = authenticationType,
Server = serverName,
Database = databaseName
};

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

// Action
cmdlet.ExecuteCmdlet();

// Assert
this.dataFactoriesClientMock.Verify(f => f.OnPremisesEncryptString(secureString, ResourceGroupName, DataFactoryName, GatewayName, credential, linkedServiceType, nonCredentialValue, authenticationType), Times.Once());
this.dataFactoriesClientMock.Verify(f => f.OnPremisesEncryptString(secureString, ResourceGroupName, DataFactoryName, GatewayName, credential, linkedServiceType, nonCredentialValue, authenticationType, serverName, databaseName), Times.Once());
this.commandRuntimeMock.Verify(f => f.WriteObject(expectedOutput), Times.Once());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
<HintPath>..\..\..\packages\Microsoft.DataFactories.Runtime.0.11.1-preview\lib\net45\Microsoft.DataFactories.Runtime.dll</HintPath>
</Reference>
<Reference Include="Microsoft.DataTransfer.Gateway.Encryption">
<HintPath>..\..\..\packages\Microsoft.DataTransfer.Gateway.Encryption.1.4.0-preview\lib\net45\Microsoft.DataTransfer.Gateway.Encryption.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.DataTransfer.Gateway.Encryption.1.5.0-preview\lib\net45\Microsoft.DataTransfer.Gateway.Encryption.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory">
<SpecificVersion>False</SpecificVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ internal DataFactoryClient DataFactoryClient
{
if (this.dataFactoryClient == null)
{
this.dataFactoryClient = new DataFactoryClient(Profile.Context);
this.dataFactoryClient = new DataFactoryClient(Profile);
}
return this.dataFactoryClient;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,14 @@ public class NewAzureDataFactoryEncryptValueCommand : DataFactoryBaseCmdlet
[Parameter(ParameterSetName = ByFactoryName, Position = 4, Mandatory = false, HelpMessage = "The windows authentication credential.")]
public PSCredential Credential { get; set; }

[Parameter(ParameterSetName = ByFactoryObject, Position = 4, Mandatory = false, HelpMessage = "The linked service type.")]
[Parameter(ParameterSetName = ByFactoryName, Position = 5, Mandatory = false, HelpMessage = "The linked service type.")]
[ValidateSet("OnPremisesSqlLinkedService", "OnPremisesFileSystemLinkedService", "OnPremisesOracleLinkedService", "OnPremisesOdbcLinkedService", IgnoreCase = true)]
[Parameter(ParameterSetName = ByFactoryObject, Position = 4, Mandatory = false,
HelpMessage = "The linked service type.")]
[Parameter(ParameterSetName = ByFactoryName, Position = 5, Mandatory = false,
HelpMessage = "The linked service type.")]
[ValidateSet("OnPremisesSqlLinkedService", "OnPremisesFileSystemLinkedService", "OnPremisesOracleLinkedService",
"OnPremisesOdbcLinkedService", "OnPremisesPostgreSqlLinkedService", "OnPremisesTeradataLinkedService",
"OnPremisesMySQLLinkedService", "OnPremisesDB2LinkedService", "OnPremisesSybaseLinkedService",
IgnoreCase = true)]
public string Type { get; set; }

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

[Parameter(ParameterSetName = ByFactoryObject, Position = 7, Mandatory = false, HelpMessage = "The server name.")]
[Parameter(ParameterSetName = ByFactoryName, Position = 8, Mandatory = false, HelpMessage = "The server name.")]
public string Server { get; set; }

[Parameter(ParameterSetName = ByFactoryObject, Position = 8, Mandatory = false, HelpMessage = "The database name.")]
[Parameter(ParameterSetName = ByFactoryName, Position = 9, Mandatory = false, HelpMessage = "The database name.")]
public string Database { get; set; }

[EnvironmentPermission(SecurityAction.Demand, Unrestricted = true)]
public override void ExecuteCmdlet()
{
Expand All @@ -85,7 +98,8 @@ public override void ExecuteCmdlet()
else
{
// On-premises encryption with Gateway
encryptedValue = DataFactoryClient.OnPremisesEncryptString(Value, ResourceGroupName, DataFactoryName, GatewayName, Credential, Type, NonCredentialValue, AuthenticationType);
encryptedValue = DataFactoryClient.OnPremisesEncryptString(Value, ResourceGroupName, DataFactoryName,
GatewayName, Credential, Type, NonCredentialValue, AuthenticationType, Server, Database);
}

WriteObject(encryptedValue);
Expand Down
Loading