Exemplo n.º 1
0
				It("rejects outbound tcp traffic", func() {
					// Failed to connect to host
					pollTaskStatus(taskGuid, "28\n")
				})
			})

			Context("with appropriate security group setting", func() {
				BeforeEach(func() {
					taskCreateRequest.EgressRules = []*models.SecurityGroupRule{
						{
							Protocol:     models.TCPProtocol,
							Destinations: []string{"9.0.0.0-89.255.255.255", "90.0.0.0-94.0.0.0"},
							Ports:        []uint32{80, 443},
						},
						{
							Protocol:     models.UDPProtocol,
							Destinations: []string{"0.0.0.0/0"},
							PortRange: &models.PortRange{
								Start: 53,
								End:   53,
							},
						},
					}
				})

				It("allows outbound tcp traffic", func() {
					pollTaskStatus(taskGuid, "0\n")
				})
			})
		})
	})
				Expect(responseRecorder.Code).To(Equal(http.StatusCreated))
			})

			It("responds with an empty body", func() {
				Expect(responseRecorder.Body.String()).To(Equal(""))
			})

			Context("when omitempty fields", func() {
				Context("are specified", func() {
					BeforeEach(func() {
						validCreateRequest.EnvironmentVariables = []*models.EnvironmentVariable{
							{Name: "var1", Value: "val1"},
							{Name: "var2", Value: "val2"},
						}
						validCreateRequest.EgressRules = []*models.SecurityGroupRule{
							{Protocol: "tcp"},
						}
					})

					It("passes them to the BBS", func() {
						Expect(fakeClient.DesireTaskCallCount()).To(Equal(1))
						_, _, def := fakeClient.DesireTaskArgsForCall(0)
						Expect(def.EnvironmentVariables).To(Equal([]*models.EnvironmentVariable{
							{Name: "var1", Value: "val1"},
							{Name: "var2", Value: "val2"},
						}))
						Expect(def.EgressRules).To(Equal([]*models.SecurityGroupRule{{Protocol: "tcp"}}))
					})
				})

				Context("when are not specified", func() {