Esempio n. 1
0
					}

					expectedVitals := boshvitals.Vitals{
						Load: []string{"foo", "bar", "baz"},
					}
					vitalsService.GetVitals = expectedVitals
					expectedVM := map[string]interface{}{"name": "vm-abc-def"}

					state, err := action.Run("full")
					Expect(err).ToNot(HaveOccurred())

					boshassert.MatchesJSONString(GinkgoT(), state.AgentID, `"my-agent-id"`)
					boshassert.MatchesJSONString(GinkgoT(), state.JobState, `"running"`)
					boshassert.MatchesJSONString(GinkgoT(), state.Deployment, `"fake-deployment"`)
					Expect(*state.Vitals).To(Equal(expectedVitals))
					boshassert.MatchesJSONMap(GinkgoT(), state.VM, expectedVM)
				})

				Describe("non-populated field formatting", func() {
					It("returns network as empty hash if not set", func() {
						specService.Spec = boshas.V1ApplySpec{NetworkSpecs: nil}
						state, err := action.Run("full")
						Expect(err).ToNot(HaveOccurred())
						boshassert.MatchesJSONString(GinkgoT(), state.NetworkSpecs, `{}`)

						// Non-empty NetworkSpecs
						specService.Spec = boshas.V1ApplySpec{
							NetworkSpecs: map[string]boshas.NetworkSpec{
								"fake-net-name": boshas.NetworkSpec{
									Fields: map[string]interface{}{"ip": "fake-ip"},
								},
Esempio n. 2
0
				Password:  "******",
				PublicKey: "some-key",
			}

			_, err := action.Run("setup", params)
			Expect(err).To(HaveOccurred())
			Expect(err.Error()).To(ContainSubstring("No default ip"))
		})

		It("ssh setup with username and password", func() {
			testSSHSetupWithGivenPassword("some-password")
		})

		It("ssh setup without password", func() {
			testSSHSetupWithGivenPassword("")
		})

		It("ssh run cleanup deletes ephemeral user", func() {
			response, err := action.Run("cleanup", SSHParams{UserRegex: "^foobar.*"})
			Expect(err).ToNot(HaveOccurred())
			Expect(platform.DeleteEphemeralUsersMatchingRegex).To(Equal("^foobar.*"))

			// Make sure empty ip field is not included in the response
			boshassert.MatchesJSONMap(GinkgoT(), response, map[string]interface{}{
				"command": "cleanup",
				"status":  "success",
			})
		})
	})
})