Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send correct content-type when creating bucket #63

Merged
merged 1 commit into from
May 25, 2023

Conversation

iyigunform3
Copy link
Contributor

@iyigunform3 iyigunform3 commented May 25, 2023

Bucket creation request must have the application/json content-type according to the runscope documentation. This content type is being enforced now and providing application/x-www-form-urlencoded causes a 415 Unsupported Media Type response.

Before the change the tests were failing with following error:

=== RUN   TestCreateBucket
[DEBUG] creating bucket test
[DEBUG]	 	request: POST /buckets url.Values{"name":[]string{"test"}, "team_uuid":[]string{"0b648b14-4e1c-49e2-aad6-013cdf0d8f5f"}}
[DEBUG]	 &http.Request{Method:"POST", URL:(*url.URL)(0xc0004d4750), Proto:"HTTP/1.1", ProtoMajor:1, ProtoMinor:1, Header:http.Header{"Accept":[]string{"application/json"}, "Authorization":[]string{"Bearer e84c44cb-2533-4a32-814c-6657e9ce3f5f"}, "Content-Type":[]string{"application/x-www-form-urlencoded"}}, Body:io.nopCloserWriterTo{Reader:(*strings.Reader)(0xc0002bcbc0)}, GetBody:(func() (io.ReadCloser, error))(0x66ff60), ContentLength:56, TransferEncoding:[]string(nil), Close:false, Host:"api.runscope.com", Form:url.Values(nil), PostForm:url.Values(nil), MultipartForm:(*multipart.Form)(nil), Trailer:http.Header(nil), RemoteAddr:"", RequestURI:"", TLS:(*tls.ConnectionState)(nil), Cancel:(<-chan struct {})(nil), Response:(*http.Response)(nil), ctx:(*context.emptyCtx)(0xc00001a140)}
[DEBUG]	 	response: 415 {"data": {}, "meta": {"status": "error"}, "error": {"status": 415, "message": "Unsupported Media Type"}}

    bucket_test.go:15: Error creating bucket: test
--- FAIL: TestCreateBucket (0.24s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x6a434d]

goroutine 107 [running]:
testing.tRunner.func1.2({0x6e8d60, 0x96f5b0})
	/usr/local/go/src/testing/testing.go:1396 +0x24e
testing.tRunner.func1()
	/usr/local/go/src/testing/testing.go:1399 +0x39f
panic({0x6e8d60, 0x96f5b0})
	/usr/local/go/src/runtime/panic.go:884 +0x212
github.com/ewilde/go-runscope.TestCreateBucket(0xc000358d00)
	/home/iyigun/go/src/github.com/ewilde/go-runscope/bucket_test.go:18 +0x10d
testing.tRunner(0xc000358d00, 0x766de8)
	/usr/local/go/src/testing/testing.go:1446 +0x10b
created by testing.(*T).Run
	/usr/local/go/src/testing/testing.go:1493 +0x35f
FAIL	github.com/ewilde/go-runscope	23.702s
?   	github.com/ewilde/go-runscope/examples	[no test files]

Bucket creation request must have the application/json content-type according to the documentation. This content type is being enforced now and providing application/x-www-form-urlencoded causes a 415 Unsupported Media Type response.
@ewilde ewilde self-requested a review May 25, 2023 10:21
@ewilde ewilde merged commit 3a494a1 into ewilde:master May 25, 2023
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants