Beispiel #1
0
        static CloudBackupTestBase()
        {
            var configuration = RavenConfiguration.CreateForTesting("foo", ResourceType.Database);

            configuration.Initialize();

            DefaultConfiguration = configuration.Backup;
        }
Beispiel #2
0
        public void CanSetupConfiguration()
        {
            var allDestinations = new HashSet <string>(BackupConfiguration._allDestinations);

            allDestinations.Remove(PeriodicBackupConfiguration.BackupDestination.None.ToString());

            var backupConfiguration = new BackupConfiguration();

            foreach (var destination in allDestinations)
            {
                backupConfiguration.AssertDestinationAllowed(destination);
            }

            backupConfiguration.AllowedDestinations = allDestinations.ToArray();
            foreach (var destination in allDestinations)
            {
                backupConfiguration.AssertDestinationAllowed(destination);
            }

            backupConfiguration.AllowedDestinations = new[] { "Amazonglacier", "Amazons3", "googleCloud" };
            backupConfiguration.ValidateAllowedDestinations();
            backupConfiguration.AssertDestinationAllowed("AmazonGlacier");
            backupConfiguration.AssertDestinationAllowed("AmazonS3");
            backupConfiguration.AssertDestinationAllowed("GoogleCloud");
            var exception = Assert.Throws <ArgumentException>(() => backupConfiguration.AssertDestinationAllowed("Google Cloud"));

            Assert.StartsWith("The selected backup destination 'Google Cloud' is not allowed in this RavenDB server", exception.Message);

            backupConfiguration.AllowedDestinations = new[] { "None" };
            foreach (var destination in allDestinations)
            {
                AssertNoneAllowedDestinations(destination);
            }

            backupConfiguration.AllowedDestinations = new[] { "nOnE" };
            foreach (var destination in allDestinations)
            {
                AssertNoneAllowedDestinations(destination);
            }

            void AssertNoneAllowedDestinations(string destination)
            {
                exception = Assert.Throws <ArgumentException>(() => backupConfiguration.AssertDestinationAllowed(destination));
                Assert.Equal("Backups are not allowed in this RavenDB server. Contact the administrator for more information.", exception.Message);
            }
        }