func (s *CinderV2Suite) TestGetVolumes() {
	Convey("Given Cinder volumes are requested", s.T(), func() {

		Convey("When authentication is required", func() {
			provider, err := openstackintel.Authenticate(th.Endpoint(), "me", "secret", "tenant")
			th.AssertNoErr(s.T(), err)
			th.CheckEquals(s.T(), s.Token, provider.TokenID)

			Convey("and GetVolumes called", func() {
				dispatch := ServiceV2{}
				volumes, err := dispatch.GetVolumes(provider)

				Convey("Then proper limits values are returned", func() {
					So(len(volumes), ShouldEqual, 2)
					So(volumes[s.Tenant1ID].Bytes, ShouldEqual, s.Vol1Size*1024*1024*1024)
					So(volumes[s.Tenant2ID].Bytes, ShouldEqual, s.Vol2Size*1024*1024*1024)
					So(volumes[s.Tenant1ID].Count, ShouldEqual, 1)
					So(volumes[s.Tenant2ID].Count, ShouldEqual, 1)
				})

				Convey("and no error reported", func() {
					So(err, ShouldBeNil)
				})
			})
		})
	})
}
func (c *collector) authenticate(cfg interface{}, tenant string) error {
	if _, found := c.providers[tenant]; !found {
		// get credentials and endpoint from configuration
		items, err := config.GetConfigItems(cfg, "endpoint", "user", "password")
		if err != nil {
			return err
		}

		endpoint := items["endpoint"].(string)
		user := items["user"].(string)
		password := items["password"].(string)

		provider, err := openstackintel.Authenticate(endpoint, user, password, tenant)
		if err != nil {
			return err
		}
		// set provider and dispatch API version based on priority
		c.providers[tenant] = provider
		c.service = services.Dispatch(provider)

		// set Commoner interface
		c.common = openstackintel.Common{}
	}

	return nil
}
func (s *CinderV2Suite) TestGetLimits() {
	Convey("Given Cinder absolute limits are requested", s.T(), func() {

		Convey("When authentication is required", func() {
			provider, err := openstackintel.Authenticate(th.Endpoint(), "me", "secret", "tenant")
			th.AssertNoErr(s.T(), err)
			th.CheckEquals(s.T(), s.Token, provider.TokenID)

			Convey("and GetLimits called", func() {
				dispatch := ServiceV2{}
				limits, err := dispatch.GetLimits(provider)

				Convey("Then proper limits values are returned", func() {
					So(limits.MaxTotalVolumes, ShouldEqual, s.MaxTotalVolumes)
					So(limits.MaxTotalVolumeGigabytes, ShouldEqual, s.MaxTotalVolumeGigabytes)
				})

				Convey("and no error reported", func() {
					So(err, ShouldBeNil)
				})
			})
		})
	})
}