func (s *productSpecSuite) TestId(c *gc.C) { toolsConstraint := tools.NewVersionedToolsConstraint(version.MustParse("1.13.0"), simplestreams.LookupParams{ Series: []string{"precise"}, Arches: []string{"amd64"}, }) ids, err := toolsConstraint.Ids() c.Assert(err, gc.IsNil) c.Assert(ids, gc.DeepEquals, []string{"com.ubuntu.juju:12.04:amd64"}) }
func registerSimpleStreamsTests() { gc.Suite(&simplestreamsSuite{ LocalLiveSimplestreamsSuite: sstesting.LocalLiveSimplestreamsSuite{ Source: simplestreams.NewURLDataSource("test", "test:", utils.VerifySSLHostnames), RequireSigned: false, DataType: tools.ContentDownload, ValidConstraint: tools.NewVersionedToolsConstraint(version.MustParse("1.13.0"), simplestreams.LookupParams{ CloudSpec: simplestreams.CloudSpec{ Region: "us-east-1", Endpoint: "https://ec2.us-east-1.amazonaws.com", }, Series: []string{"precise"}, Arches: []string{"amd64", "arm"}, }), }, }) gc.Suite(&signedSuite{}) }
func (s *signedSuite) TestSignedToolsMetadata(c *gc.C) { signedSource := simplestreams.NewURLDataSource("test", "signedtest://host/signed", utils.VerifySSLHostnames) toolsConstraint := tools.NewVersionedToolsConstraint(version.MustParse("1.13.0"), simplestreams.LookupParams{ CloudSpec: simplestreams.CloudSpec{"us-east-1", "https://ec2.us-east-1.amazonaws.com"}, Series: []string{"precise"}, Arches: []string{"amd64"}, }) toolsMetadata, resolveInfo, err := tools.Fetch( []simplestreams.DataSource{signedSource}, simplestreams.DefaultIndexPath, toolsConstraint, true) c.Assert(err, gc.IsNil) c.Assert(len(toolsMetadata), gc.Equals, 1) c.Assert(toolsMetadata[0].Path, gc.Equals, "tools/releases/20130806/juju-1.13.1-precise-amd64.tgz") c.Assert(resolveInfo, gc.DeepEquals, &simplestreams.ResolveInfo{ Source: "test", Signed: true, IndexURL: "signedtest://host/signed/streams/v1/index.sjson", MirrorURL: "", }) }
func setupSimpleStreamsTests(t *testing.T) { if *live { if *vendor == "" { t.Fatal("missing vendor") } var ok bool var testData liveTestData if testData, ok = liveUrls[*vendor]; !ok { keys := reflect.ValueOf(liveUrls).MapKeys() t.Fatalf("Unknown vendor %s. Must be one of %s", *vendor, keys) } registerLiveSimpleStreamsTests(testData.baseURL, tools.NewVersionedToolsConstraint(version.MustParse("1.13.0"), simplestreams.LookupParams{ CloudSpec: testData.validCloudSpec, Series: []string{version.Current.Series}, Arches: []string{"amd64"}, }), testData.requireSigned) } registerSimpleStreamsTests() }
func (s *simplestreamsSuite) TestFetch(c *gc.C) { for i, t := range fetchTests { c.Logf("test %d", i) var toolsConstraint *tools.ToolsConstraint if t.version == "" { toolsConstraint = tools.NewGeneralToolsConstraint(t.major, t.minor, t.released, simplestreams.LookupParams{ CloudSpec: simplestreams.CloudSpec{"us-east-1", "https://ec2.us-east-1.amazonaws.com"}, Series: []string{t.series}, Arches: t.arches, }) } else { toolsConstraint = tools.NewVersionedToolsConstraint(version.MustParse(t.version), simplestreams.LookupParams{ CloudSpec: simplestreams.CloudSpec{"us-east-1", "https://ec2.us-east-1.amazonaws.com"}, Series: []string{t.series}, Arches: t.arches, }) } // Add invalid datasource and check later that resolveInfo is correct. invalidSource := simplestreams.NewURLDataSource("invalid", "file://invalid", utils.VerifySSLHostnames) tools, resolveInfo, err := tools.Fetch( []simplestreams.DataSource{invalidSource, s.Source}, simplestreams.DefaultIndexPath, toolsConstraint, s.RequireSigned) if !c.Check(err, gc.IsNil) { continue } for _, tm := range t.tools { tm.FullPath, err = s.Source.URL(tm.Path) c.Assert(err, gc.IsNil) } c.Check(tools, gc.DeepEquals, t.tools) c.Check(resolveInfo, gc.DeepEquals, &simplestreams.ResolveInfo{ Source: "test", Signed: s.RequireSigned, IndexURL: "test:/streams/v1/index.json", MirrorURL: "", }) } }