Exemple #1
0
func (s *backupsDownloadSuite) sendValid(c *gc.C) *http.Response {
	meta := backupstesting.NewMetadata()
	archive, err := backupstesting.NewArchiveBasic(meta)
	c.Assert(err, jc.ErrorIsNil)
	s.fake.Meta = meta
	s.fake.Archive = ioutil.NopCloser(archive)
	s.body = archive.Bytes()

	ctype := apihttp.CTypeJSON
	body := s.newBody(c, meta.ID())
	resp, err := s.authRequest(c, "GET", s.backupURL(c), ctype, body)
	c.Assert(err, jc.ErrorIsNil)
	return resp
}
Exemple #2
0
// sendValid sends a valid GET request to the backups endpoint
// and returns the response and the expected contents of the
// archive if the request succeeds.
func (s *backupsDownloadSuite) sendValidGet(c *gc.C) (resp *http.Response, archiveBytes []byte) {
	meta := backupstesting.NewMetadata()
	archive, err := backupstesting.NewArchiveBasic(meta)
	c.Assert(err, jc.ErrorIsNil)
	archiveBytes = archive.Bytes()
	s.fake.Meta = meta
	s.fake.Archive = ioutil.NopCloser(archive)

	return s.authRequest(c, httpRequestParams{
		method:      "GET",
		url:         s.backupURL(c),
		contentType: params.ContentTypeJSON,
		jsonBody: params.BackupsDownloadArgs{
			ID: meta.ID(),
		},
	}), archiveBytes
}