Giter Club home page Giter Club logo

govcr's People

Contributors

abourget avatar allensaundersx avatar klauspost avatar richardwilkes avatar seborama avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

govcr's Issues

json: unsupported type: func(...

I'm using govcr but when I have logging turned on I see the following message:

2018/07/25 06:21:15 json: unsupported type: func(string, []uint8, int) ([]uint8, bool)

Also, after running the test I don't see any new files at the CassettePath I have configured.

HTTPS requests recording

Hi @seborama!

I tried your lib, but had a problem with it that forced me to use https://github.com/dnaeon/go-vcr instead.

My use case: I inject your *http.Client into gorequest.SuperAgent and that into library that I maintain.
All requests are HTTPS. The problem is, the records contain the body encrypted.
Firstly, that's hard to maintain. Secondly, it doesn't match for request body, so I can't replay.

Remove "Path" from cassettes

It seems that for no real reason, the full path is stored in a cassette:

{
  "Name": "TestUnauth.gz",
  "Path": "/home/klaus/gopath/src/github.com/app/testdata",
  "Tracks": [ ....

This creates problems for me, when I run the cassette as part of a CI test, since the cassette is no longer at this path. Therefore I get an unexpected mkdir /home/klaus: permission denied when it wants to add to the cassette.

I don't see any reason to have this information inside the cassette since it must be provided anyway for loading it, and it only causes problems. So I'd propose to remove it.

Explicit save() of cassettes?

Hi,

Thanks for a great tool! I use it extensively for running test. one thing I've noticed is that whenever in captuing mode, saving http traffic, it appears to save the cassette to disk for each new track. It appears to entail both json marshaling and a disk write. Some of my tests are long, with thousands of requests, and this amount of writing cause the capturing phase to grind to a crawl when the cassette gets larger in size.

Would it be possible to defer the (json rendering and) writing to disk until an explicit .Save() call is made?

Thanks!

Handle concurrent roundtrips better

Typically you would expect an http.RoundTripper to handle concurrent requests.

If we look at the exiting Roundtripper it will cause race conditions on concurrent access.

A "simple" solution could be to put a mu sync.Mutex in the vcrTransport and add t.mu.Lock() / defer t.mu.Unlock() to the RoundTrip function. This could serialize roundtrips so only one can run at the time. It will not guarantee any order of recordings, but if you do concurrent requests you wouldn't expect to.

Version tags don't all work with Go modules

In an empty package, trying to load govcr with Go modules grabs some older versions:

$ cat go.mod 
module example

go 1.12

$ go get gopkg.in/seborama/govcr.v2
$ go get gopkg.in/seborama/govcr.v3
$ go get gopkg.in/seborama/govcr.v4
go: finding gopkg.in/seborama/govcr.v4 latest

$ cat go.mod 
module example

go 1.12

require (
	gopkg.in/seborama/govcr.v2 v2.2.1 // indirect
	gopkg.in/seborama/govcr.v3 v3.0.1 // indirect
	gopkg.in/seborama/govcr.v4 v4.0.0-20190303132007-6b478b087ffb // indirect
)

The latest v2 tag seems to be 2.4.2, but it doesn't get found because it's missing the v prefix (note: it's also missing from gopkg.in.) The latest v3 tag is v3.2 and the latest v4 tag is v4.4. However, modules seem to require semver which needs 3-component versions, i.e., quoting from the Modules wiki page:

Modules must be semantically versioned according to semver, usually in the form v(major).(minor).(patch), such as v0.1.0, v1.2.3, or v1.5.0-rc.1. The leading v is required. If using Git, tag released commits with their versions. Public and private module repositories and proxies are becoming available (see FAQ below).

So if these were re-tagged with a trailing .0 (e.g., v4.4.0), I think this would work (though I'm not totally sure, Go modules are fancy new things.)

Ability to remove sensitive information from responses

Sensitive headers (e.g., Set-Cookie) are stored in the cassette currently. Is there a way to ensure they are not stored?

Currently, I am injecting a custom RoundTripper:

func (tr *testScrubTransport) RoundTrip(req *http.Request) (*http.Response, error) {
	resp, err := tr.Original.RoundTrip(req)
	if err == nil {
		// Scrub sensitive material here
		resp.Header.Del("Set-Cookie")
	}
	return resp, err
}

But it would be nice if we could use govcr's ResponseFilter machinery for this.

Using govcr as audit tool

Hi @seborama!

Thank you for govcr, is a fantastic library.

I am planning to use this library for 2 purposes:

  1. Mock test responses
  2. Store the cassettes as a audit tool for a project

The second use is not the intended library use. Do you know a better library to store network requests in golang? If not, what will be the best strategy to turn govcr agnostic to persistance (i.e. .cassette files, databases, etc..)?

Thanks,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.