public void TestOnPremDatasourceEncryptionSQLAuth() { SecureString secureString = new SecureString(); string expectedOutput = "My encrypted string " + Guid.NewGuid(); string linkedServiceType = "OnPremisesSqlLinkedService"; string nonCredentialValue = "Driver=mydriver;server=myserver"; string authenticationType = "Basic"; string serverName = null; string databaseName = null; var cmdlet = new NewAzureDataFactoryEncryptValueCommand { CommandRuntime = this.commandRuntimeMock.Object, DataFactoryClient = this.dataFactoriesClientMock.Object, Value = secureString, ResourceGroupName = ResourceGroupName, DataFactoryName = DataFactoryName, GatewayName = GatewayName, Type = linkedServiceType, NonCredentialValue = nonCredentialValue, AuthenticationType = authenticationType, Server = serverName, Database = databaseName }; // Arrange 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, serverName, databaseName), Times.Once()); this.commandRuntimeMock.Verify(f => f.WriteObject(expectedOutput), Times.Once()); }
public void TestOnPermDatasourceEncryptionWithRawJsonContent() { SecureString secureString = new SecureString(); string expectedOutput = "My encrypted string " + Guid.NewGuid(); var cmdlet = new NewAzureDataFactoryEncryptValueCommand { CommandRuntime = this.commandRuntimeMock.Object, DataFactoryClient = this.dataFactoriesClientMock.Object, Value = secureString, ResourceGroupName = ResourceGroupName, DataFactoryName = DataFactoryName, GatewayName = GatewayName }; // Arrange this.dataFactoriesClientMock.Setup(f => f.OnPremisesEncryptString(secureString, ResourceGroupName, DataFactoryName, GatewayName)).Returns(expectedOutput); // Action cmdlet.ExecuteCmdlet(); // Assert this.dataFactoriesClientMock.Verify(f => f.OnPremisesEncryptString(secureString, ResourceGroupName, DataFactoryName, GatewayName), Times.Once()); this.commandRuntimeMock.Verify(f => f.WriteObject(expectedOutput), Times.Once()); }
public void TestOnPremDatasourceEncryptionWinAuth() { SecureString secureString = new SecureString(); string expectedOutput = "My encrypted string " + Guid.NewGuid(); string winAuthUserName = "******"; SecureString winAuthPassword = new SecureString(); PSCredential credential = new PSCredential(winAuthUserName, winAuthPassword); string linkedServiceType = "OnPremisesFileSystemLinkedService"; var cmdlet = new NewAzureDataFactoryEncryptValueCommand { CommandRuntime = this.commandRuntimeMock.Object, DataFactoryClient = this.dataFactoriesClientMock.Object, Value = secureString, ResourceGroupName = ResourceGroupName, DataFactoryName = DataFactoryName, GatewayName = GatewayName, Credential = credential, Type = linkedServiceType }; // Arrange this.dataFactoriesClientMock.Setup(f => f.OnPremisesEncryptString(secureString, ResourceGroupName, DataFactoryName, GatewayName, credential, linkedServiceType)).Returns(expectedOutput); // Action cmdlet.ExecuteCmdlet(); // Assert this.dataFactoriesClientMock.Verify(f => f.OnPremisesEncryptString(secureString, ResourceGroupName, DataFactoryName, GatewayName, credential, linkedServiceType), Times.Once()); this.commandRuntimeMock.Verify(f => f.WriteObject(expectedOutput), Times.Once()); }