Exemplo n.º 1
0
	Context("when a LRP that tries to do privileged things is requested", func() {
		var lrpRequest receptor.DesiredLRPCreateRequest

		BeforeEach(func() {
			lrpRequest = helpers.PrivilegedLRPCreateRequest(helpers.GenerateGuid())
		})

		JustBeforeEach(func() {
			err := receptorClient.CreateDesiredLRP(lrpRequest)
			Expect(err).NotTo(HaveOccurred())
		})

		Context("when the LRP is privileged", func() {
			BeforeEach(func() {
				lrpRequest.Privileged = true
			})

			It("succeeds", func() {
				Eventually(helpers.ResponseCodeFromHostPoller(componentMaker.Addresses.Router, helpers.DefaultHost)).Should(Equal(http.StatusOK))
			})
		})

		Context("when the LRP is not privileged", func() {
			BeforeEach(func() {
				lrpRequest.Privileged = false
			})

			It("fails", func() {
				Eventually(helpers.ResponseCodeFromHostPoller(componentMaker.Addresses.Router, helpers.DefaultHost)).Should(Equal(http.StatusInternalServerError))
			})