Пример #1
0
func (s *ReleaseTestSuite) TestSetup(c *C) {
	c.Assert(release.Setup(c.MkDir()), IsNil)
	c.Check(release.String(), Equals, "16-core")
	rel := release.Get()
	c.Check(rel.Flavor, Equals, "core")
	c.Check(rel.Series, Equals, "16")
}
Пример #2
0
func (s *SnapTestSuite) TestUbuntuStoreRepositoryHeaders(c *C) {
	req, err := http.NewRequest("GET", "http://example.com", nil)
	c.Assert(err, IsNil)

	setUbuntuStoreHeaders(req)

	c.Assert(req.Header.Get("X-Ubuntu-Release"), Equals, release.String())
}
Пример #3
0
// small helper that sets the correct http headers for the ubuntu store
func setUbuntuStoreHeaders(req *http.Request) {
	req.Header.Set("Accept", "application/hal+json")

	// frameworks
	frameworks, _ := ActiveSnapIterByType(BareName, pkg.TypeFramework)
	req.Header.Set("X-Ubuntu-Frameworks", strings.Join(addCoreFmk(frameworks), ","))
	req.Header.Set("X-Ubuntu-Architecture", string(Architecture()))
	req.Header.Set("X-Ubuntu-Release", release.String())
	req.Header.Set("X-Ubuntu-Device-Channel", release.Get().Channel)

	if storeID := os.Getenv("UBUNTU_STORE_ID"); storeID != "" {
		req.Header.Set("X-Ubuntu-Store", storeID)
	} else if storeID := StoreID(); storeID != "" {
		req.Header.Set("X-Ubuntu-Store", storeID)
	}

	// sso
	ssoToken, err := ReadStoreToken()
	if err == nil {
		req.Header.Set("Authorization", oauth.MakePlaintextSignature(&ssoToken.Token))
	}
}
Пример #4
0
func (s *ReleaseTestSuite) TestOverride(c *C) {
	rel := release.Release{Flavor: "personal", Series: "10.06"}
	release.Override(rel)
	c.Check(release.String(), Equals, "10.06-personal")
	c.Check(release.Get(), DeepEquals, rel)
}