Ejemplo n.º 1
0
        public async Task BuildDeleteImage_NotOwner()
        {
            var c = GetController();

            TestHelper.SetupUser(c);
            var bresult = (await c.CreateBuild()).Id;

            Assert.True(c.HttpContext.Response.StatusCode == 200);

            c.Request.HttpContext.Request.ContentType = c.ValidContentTypes[0];
            var iresult = await c.AddImage(bresult);

            Assert.True(c.HttpContext.Response.StatusCode == 200);

            var dpi = new BuildController.DeleteImageParamInfo
            {
                Build = bresult,
                Image = iresult
            };

            TestHelper.SetupUser(c, "abc");
            var dresult = await c.DeleteImage(dpi);

            Assert.True(c.HttpContext.Response.StatusCode == 403);
        }
Ejemplo n.º 2
0
        public async Task BuildAddImage_DeleteImage_Success()
        {
            var c = GetController();

            TestHelper.SetupUser(c);
            var bresult = (await c.CreateBuild()).Id;

            Assert.True(c.HttpContext.Response.StatusCode == 200);

            c.Request.HttpContext.Request.ContentType = c.ValidContentTypes[0];
            var iresult = await c.AddImage(bresult);

            Assert.True(c.HttpContext.Response.StatusCode == 200);

            // check to see if the image exists
            var newb = await c.GetById(bresult);

            Assert.True(newb.Images[0].Id == iresult);

            var dpi = new BuildController.DeleteImageParamInfo
            {
                Build = bresult,
                Image = iresult
            };

            var dresult = await c.DeleteImage(dpi);

            Assert.True(c.HttpContext.Response.StatusCode == 200);
        }
Ejemplo n.º 3
0
        public async Task BuildDeleteImage_BadBuild()
        {
            var c = GetController();

            TestHelper.SetupUser(c);
            var dpi = new BuildController.DeleteImageParamInfo
            {
                Build = "asdf",
                Image = "asdf"
            };

            var dresult = await c.DeleteImage(dpi);

            Assert.True(c.HttpContext.Response.StatusCode == 404);
        }