Пример #1
0
        public async Task GetNetworksFormsCorrectUrlAndMethod()
        {
            var client =
                new NetworkServiceRestClient(GetValidContext(), this.ServiceLocator);

            await client.GetNetworks();

            Assert.AreEqual(string.Format("{0}/networks", endpoint + "v2.0"), this.simulator.Uri.ToString());
            Assert.AreEqual(HttpMethod.Get, this.simulator.Method);
        }
Пример #2
0
        public async Task CreateFloatingIpFormsCorrectUrlAndMethod()
        {
            var client =
                new NetworkServiceRestClient(GetValidContext(), this.ServiceLocator);

            await client.CreateFloatingIp("12345");

            Assert.AreEqual(string.Format("{0}/floatingips", endpoint + "v2.0"), this.simulator.Uri.ToString());
            Assert.AreEqual(HttpMethod.Post, this.simulator.Method);
        }
Пример #3
0
        public async Task GetNetworksIncludesAuthHeader()
        {
            var client =
                new NetworkServiceRestClient(GetValidContext(), this.ServiceLocator);

            await client.GetNetworks();

            Assert.IsTrue(this.simulator.Headers.ContainsKey("X-Auth-Token"));
            Assert.AreEqual(this.authId, this.simulator.Headers["X-Auth-Token"]);
        }
Пример #4
0
        public async Task DeleteFloatingIpFormsCorrectUrlAndMethod()
        {
            var floatingIpId = "12345";
            var client       =
                new NetworkServiceRestClient(GetValidContext(), this.ServiceLocator);

            await client.DeleteFloatingIp(floatingIpId);

            Assert.AreEqual(string.Format("{0}/floatingips/{1}", endpoint + "v2.0", floatingIpId), this.simulator.Uri.ToString());
            Assert.AreEqual(HttpMethod.Delete, this.simulator.Method);
        }
Пример #5
0
        public async Task CanDeleteFloatinIp()
        {
            this.simulator.FloatingIps.Add(new FloatingIp("12345", "172.0.0.1", FloatingIpStatus.Active));
            var client =
                new NetworkServiceRestClient(GetValidContext(), this.ServiceLocator);

            var resp = await client.DeleteFloatingIp("12345");

            Assert.AreEqual(HttpStatusCode.NoContent, resp.StatusCode);

            Assert.AreEqual(0, this.simulator.FloatingIps.Count);
        }
Пример #6
0
        public async Task CanCreateFloatinIp()
        {
            var client =
                new NetworkServiceRestClient(GetValidContext(), this.ServiceLocator);

            var resp = await client.CreateFloatingIp("12345");

            Assert.AreEqual(HttpStatusCode.Created, resp.StatusCode);

            var respContent = TestHelper.GetStringFromStream(resp.Content);

            Assert.IsTrue(respContent.Length > 0);
        }
Пример #7
0
        public async Task CanGetFloatinIp()
        {
            this.simulator.FloatingIps.Add(new OpenStack.Network.FloatingIp("12345", "172.0.0.1", FloatingIpStatus.Active));

            var client =
                new NetworkServiceRestClient(GetValidContext(), this.ServiceLocator);

            var resp = await client.GetFloatingIp("12345");

            Assert.AreEqual(HttpStatusCode.OK, resp.StatusCode);

            var respContent = TestHelper.GetStringFromStream(resp.Content);

            Assert.IsTrue(respContent.Length > 0);
        }
Пример #8
0
        public async Task CreateFloatinIpFormCorrectBody()
        {
            var client =
                new NetworkServiceRestClient(GetValidContext(), this.ServiceLocator);

            var resp = await client.CreateFloatingIp("12345");

            Assert.AreEqual(HttpStatusCode.Created, resp.StatusCode);

            this.simulator.Content.Position = 0;
            var body  = TestHelper.GetStringFromStream(this.simulator.Content);
            var ipObj = JObject.Parse(body);

            Assert.IsNotNull(ipObj);
            Assert.IsNotNull(ipObj["floatingip"]);
            Assert.IsNotNull(ipObj["floatingip"]["floating_network_id"]);
            Assert.AreEqual("12345", (string)ipObj["floatingip"]["floating_network_id"]);
        }