Ejemplo n.º 1
0
        public void CanCreateGetListDeleteVaultTest()
        {
            using (var context = MockContext.Start(this.GetType()))
            {
                using (RecoveryServicesTestBase _testFixture = new RecoveryServicesTestBase(context))
                {
                    string vaultName  = VaultDefinition.TestCrud.VaultName;
                    string vaultName2 = VaultDefinition.TestList.VaultName;

                    _testFixture.CreateVault(vaultName);
                    var vault = _testFixture.GetVault(vaultName);
                    Assert.NotNull(vault);

                    _testFixture.CreateVault(vaultName2);
                    var vaults = _testFixture.ListVaults();
                    Assert.NotNull(vaults);
                    Assert.NotEmpty(vaults);
                    Assert.Contains(vaults, v => v.Name == vaultName);
                    Assert.Contains(vaults, v => v.Name == vaultName2);

                    _testFixture.DeleteVault(vaultName2);
                    Assert.Throws <CloudException>(() =>
                    {
                        _testFixture.GetVault(vaultName2);
                    });
                }
            }
        }
Ejemplo n.º 2
0
        public void GetAndUpdateBackupVaultAndStorageConfigTest()
        {
            using (var context = MockContext.Start(this.GetType()))
            {
                using (RecoveryServicesTestBase _testFixture = new RecoveryServicesTestBase(context))
                {
                    string vaultName = VaultDefinition.TestCrud.VaultName;

                    _testFixture.CreateVault(vaultName);
                    var vault = _testFixture.GetVault(vaultName);
                    Assert.NotNull(vault);

                    var vaultConfig = _testFixture.GetVaultConfig(vaultName);

                    vaultConfig.EnhancedSecurityState = EnhancedSecurityState.Disabled;
                    Assert.Throws <CloudException>(() =>
                    {
                        var vaultConfig2 = _testFixture.UpdateVaultConfig(vaultName, vaultConfig);
                    });

                    var storageConfig = _testFixture.GetStorageConfig(vaultName);
                    storageConfig.StorageModelType = StorageModelType.LocallyRedundant;
                    _testFixture.UpdateStorageConfig(vaultName, storageConfig);

                    var storageConfig2 = _testFixture.GetStorageConfig(vaultName);
                    Assert.Equal(storageConfig2.StorageModelType, StorageModelType.LocallyRedundant);
                }
            }
        }
Ejemplo n.º 3
0
        public void CanCreateGetListDeleteVaultExtendedInfoTest()
        {
            using (var context = MockContext.Start(this.GetType()))
            {
                using (RecoveryServicesTestBase _testFixture = new RecoveryServicesTestBase(context))
                {
                    string vaultName = VaultDefinition.TestCrud.VaultName;

                    _testFixture.CreateVault(vaultName);
                    var vault = _testFixture.GetVault(vaultName);
                    Assert.NotNull(vault);

                    Models.VaultExtendedInfoResource extendedInfo = null;
                    try
                    {
                        extendedInfo = _testFixture.GetVaultExtendedInfo(vault);
                    }
                    catch (CloudException ex)
                    {
                        if (ex.Response.StatusCode != HttpStatusCode.NotFound)
                        {
                            throw;
                        }
                    }

                    if (extendedInfo == null)
                    {
                        extendedInfo = _testFixture.CreateVaultExtendedInfo(vault);
                    }

                    Assert.NotNull(extendedInfo.IntegrityKey);
                }
            }
        }
        public void RetrieveVaultUsages()
        {
            using (var context = MockContext.Start(this.GetType().FullName))
            {
                using (RecoveryServicesTestBase _testFixture = new RecoveryServicesTestBase(context))
                {
                    string vaultName = VaultDefinition.TestCrud.VaultName;

                    _testFixture.CreateVault(vaultName);
                    var vault = _testFixture.GetVault(vaultName);
                    Assert.NotNull(vault);

                    var vaults = _testFixture.ListVaults();
                    Assert.NotNull(vaults);
                    Assert.NotEmpty(vaults);
                    Assert.Contains(vaults, v => v.Name == vaultName);

                    var response = _testFixture.ListVaultUsages(vaultName);

                    Assert.NotNull(response);
                    Assert.NotEmpty(response);
                    foreach (var usage in response)
                    {
                        Assert.NotNull(usage.Name.Value);
                        Assert.NotNull(usage.Unit);
                        Assert.NotNull(usage.CurrentValue);
                        Assert.NotNull(usage.Limit);
                    }

                    var replicationResponse = _testFixture.ListReplicationUsages(vaultName);

                    Assert.NotNull(replicationResponse);
                    Assert.Empty(replicationResponse);
                }
            }
        }