Ejemplo n.º 1
0
        public async Task CanUseFirewall()
        {
            Debug.WriteLine ("Creating firewall rule");
            var rule = new FirewallRule("TestRule1", "0.0.0.0", "255.255.255.255");
            await DatabaseServer.AddFirewallRuleAsync(rule);

            Debug.WriteLine("Retrieving firewall rule");
            var retrievedRule = (await DatabaseServer.FirewallRules.AsTask()).SingleOrDefault(r => r.Name == "TestRule1");
            Assert.IsNotNull(retrievedRule);
            Assert.AreEqual(retrievedRule.StartIpAddress, rule.StartIpAddress);
            Assert.AreEqual(retrievedRule.EndIpAddress, rule.EndIpAddress);

            var cxString = "Data Source=tcp:" + DatabaseServer.Name + ".database.windows.net;User ID=testadmin;Password="******";Initial Catalog=master;Encrypt=true";

            using (var cx = new SqlConnection(cxString))
            {
                Debug.WriteLine("Testing SQL connection");
                cx.Open();
                Assert.AreEqual(1, new SqlCommand("SELECT COUNT(*) FROM sys.firewall_rules", cx).ExecuteScalar());
            }

            Debug.WriteLine("Deleting firewall rule");
            await rule.DeleteAsync();

            Debug.WriteLine("Verifying firewall rule deletion");
            var deletedRule = (await DatabaseServer.FirewallRules.AsTask()).SingleOrDefault(r => r.Name == "TestRule1");
            Assert.IsNull(deletedRule);
        }
Ejemplo n.º 2
0
 public Task AddFirewallRuleAsync(FirewallRule rule)
 {
     return(rule.CreateAsync(this));
 }
Ejemplo n.º 3
0
 public Task AddFirewallRule(FirewallRule rule)
 {
     return(AddFirewallRuleAsync(rule));
 }
Ejemplo n.º 4
0
 public Task AddFirewallRuleAsync(FirewallRule rule)
 {
     return rule.CreateAsync(this);
 }
Ejemplo n.º 5
0
 public Task AddFirewallRule(FirewallRule rule)
 {
     return AddFirewallRuleAsync(rule);
 }