public async Task GetComputeImageFormsCorrectUrlAndMethod() { var imageId = "12345"; var client = new ComputeServiceRestClient(GetValidContext(), this.ServiceLocator); await client.GetImage(imageId); Assert.AreEqual(string.Format("{0}/images/{1}", endpoint, imageId), this.simulator.Uri.ToString()); Assert.AreEqual(HttpMethod.Get, this.simulator.Method); }
public async Task CanGetImage() { var imageId = "12345"; var created = DateTime.UtcNow.Subtract(TimeSpan.FromMinutes(10)); var updated = DateTime.UtcNow.Subtract(TimeSpan.FromMinutes(1)); this.simulator.Images.Add(new ComputeImage(imageId, "tiny", new Uri("http://testcomputeendpoint.com/v2/1234567890/flavors/1"), new Uri("http://testcomputeendpoint.com/1234567890/flavors/1"), new Dictionary<string, string>(), "ACTIVE", created, updated, 10, 512, 100)); var client = new ComputeServiceRestClient(GetValidContext(), this.ServiceLocator); var resp = await client.GetImage(imageId); Assert.AreEqual(HttpStatusCode.OK, resp.StatusCode); var respContent = TestHelper.GetStringFromStream(resp.Content); Assert.IsTrue(respContent.Length > 0); }
public async Task GetComputeImageIncludesAuthHeader() { var client = new ComputeServiceRestClient(GetValidContext(), this.ServiceLocator); await client.GetImage("12345"); Assert.IsTrue(this.simulator.Headers.ContainsKey("X-Auth-Token")); Assert.AreEqual(this.authId, this.simulator.Headers["X-Auth-Token"]); }