示例#1
0
func getRabbitMQEndpoint(endpoint plugin.ShieldEndpoint) (RabbitMQEndpoint, error) {
	url, err := endpoint.StringValue("rmq_url")
	if err != nil {
		return RabbitMQEndpoint{}, err
	}

	user, err := endpoint.StringValue("rmq_username")
	if err != nil {
		return RabbitMQEndpoint{}, err
	}

	passwd, err := endpoint.StringValue("rmq_password")
	if err != nil {
		return RabbitMQEndpoint{}, err
	}

	sslValidate, err := endpoint.BooleanValue("skip_ssl_validation")
	if err != nil {
		return RabbitMQEndpoint{}, err
	}

	return RabbitMQEndpoint{
		Username:          user,
		Password:          passwd,
		URL:               url,
		SkipSSLValidation: sslValidate,
	}, nil
}
示例#2
0
			Expect(got).Should(Equal(""))
			Expect(err).Should(HaveOccurred())
			Expect(err).Should(MatchError(plugin.EndpointDataTypeMismatchError{Key: "boolVal", DesiredType: "string"}))
		})
		It("errors out when pointed at a nonexistant key", func() {
			got, err := endpoint.StringValue("doesnotexist")
			Expect(got).Should(Equal(""))
			Expect(err).Should(HaveOccurred())
			Expect(err).Should(MatchError(plugin.EndpointMissingRequiredDataError{Key: "doesnotexist"}))
		})
	})
	Describe("BooleanVal", func() {
		It("returns a bool from the endpoint, when provided the right key", func() {
			expected := true

			got, err := endpoint.BooleanValue("boolVal")
			Expect(got).Should(BeEquivalentTo(expected))
			Expect(err).ShouldNot(HaveOccurred())
		})
		It("errors out when not pointed at a bool", func() {
			got, err := endpoint.BooleanValue("stringVal")
			Expect(got).Should(Equal(false))
			Expect(err).Should(HaveOccurred())
			Expect(err).Should(MatchError(plugin.EndpointDataTypeMismatchError{Key: "stringVal", DesiredType: "boolean"}))
		})
		It("errors out when pointed at a nonexistant key", func() {
			got, err := endpoint.BooleanValue("doesnotexist")
			Expect(got).Should(Equal(false))
			Expect(err).Should(HaveOccurred())
			Expect(err).Should(MatchError(plugin.EndpointMissingRequiredDataError{Key: "doesnotexist"}))
		})