func UseTestMetadata(files map[string]string) { if files != nil { testRoundTripper.Sub = jujutest.NewCannedRoundTripper(files, nil) metadataHost = "test:" } else { testRoundTripper.Sub = nil metadataHost = origMetadataHost } }
// Set Metadata requests to be served by the filecontent supplied. func UseTestMetadata(metadata map[string]string) { if len(metadata) != 0 { testRoundTripper.Sub = jujutest.NewCannedRoundTripper(metadata, nil) metadataHost = "test:" } else { testRoundTripper.Sub = nil metadataHost = origMetadataHost } }
// UseTestImageData causes the given content to be served // when the ec2 client asks for image data. func UseTestImageData(files map[string]string) { if files != nil { testRoundTripper.Sub = jujutest.NewCannedRoundTripper(files, nil) imagemetadata.DefaultBaseURL = "test:" signedImageDataOnly = false } else { signedImageDataOnly = true testRoundTripper.Sub = nil imagemetadata.DefaultBaseURL = origImagesUrl } }
func (s *BootstrapSuite) SetUpSuite(c *C) { s.LoggingSuite.SetUpSuite(c) s.MgoSuite.SetUpSuite(c) stateInfo := environs.BootstrapState{ StateInstances: []instance.Id{instance.Id("dummy.instance.id")}, } stateData, err := goyaml.Marshal(stateInfo) c.Assert(err, IsNil) content := map[string]string{"/" + environs.StateFile: string(stateData)} testRoundTripper.Sub = jujutest.NewCannedRoundTripper(content, nil) s.providerStateURLFile = filepath.Join(c.MkDir(), "provider-state-url") providerStateURLFile = s.providerStateURLFile }
// prepareSimpleStreamsResponse sets up a fake response for our query to // SimpleStreams. // // It returns a cleanup function, which you must call to reset things when // done. func prepareSimpleStreamsResponse(location, series, release, arch, json string) func() { fakeURL := fakeSimpleStreamsScheme + "://" originalURLs := baseURLs baseURLs = []string{fakeURL} originalSignedOnly := signedImageDataOnly signedImageDataOnly = false // Generate an index. It will point to an Azure index with the // caller's json. index := fmt.Sprintf(` { "index": { "com.ubuntu.cloud:released:%s": { "updated": "Tue, 30 Jul 2013 10:24:31 +0000", "clouds": [ { "region": %q, "endpoint": "https://management.core.windows.net/" } ], "cloudname": "azure", "datatype": "image-ids", "format": "products:1.0", "products": [ "com.ubuntu.cloud:server:%s:%s" ], "path": "/v1/azure.json" } }, "updated": "Tue, 30 Jul 2013 10:24:31 +0000", "format": "index:1.0" } `, series, location, release, arch) files := map[string]string{ "/v1/index.json": index, "/v1/azure.json": json, } testRoundTripper.Sub = jujutest.NewCannedRoundTripper(files, nil) return func() { baseURLs = originalURLs signedImageDataOnly = originalSignedOnly testRoundTripper.Sub = nil } }
func (s *simplestreamsSuite) SetUpSuite(c *gc.C) { s.liveSimplestreamsSuite.SetUpSuite(c) testRoundTripper.Sub = jujutest.NewCannedRoundTripper( imageData, map[string]int{"test://unauth": http.StatusUnauthorized}) }