pancho horrillo
34a5960b3c
doc: fix wording
2019-11-27 16:13:32 +01:00
pancho horrillo
53b326cb7b
doc: style fixes, example code fixes and clarifications
2019-11-27 16:07:23 +01:00
pancho horrillo
530fad17c9
doc: fix typo
2019-11-27 07:53:56 +01:00
pancho horrillo and Hector Hurtado
d08c6c72e7
doc: more work on _brainstorming.rst
...
Co-authored-by: Hector Hurtado <hector.hurtado@bbva.com >
2019-11-25 18:05:50 +01:00
pancho horrillo
6b2e2dfb28
RELEASE-v0.3.0.md: fix title
2019-11-22 17:03:54 +01:00
pancho horrillo
235375c199
RELEASE-v0.3.0.md: fix title
2019-11-22 16:51:19 +01:00
pancho horrillo
2f70938dc4
RELEASE-v0.3.0.md: fix link format and main title
2019-11-22 15:42:56 +01:00
pancho horrillo
07c6c42b73
Add release notes for v0.3.0
2019-11-22 15:39:19 +01:00
pancho horrillo
ce83cac13e
README.md: minor style fixes
2019-11-22 14:20:10 +01:00
pancho horrillo
0b0defd132
README.md: misc style fixes
2019-11-22 14:15:24 +01:00
pancho horrillo and Roberto Abdelkader Martínez Pérez
26145cba79
doc: updates to route_matching section
...
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com >
2019-11-22 12:13:25 +01:00
pancho horrillo and Roberto Abdelkader Martínez Pérez
f9867fb269
doc: add sections on theory/{routes,route_matching}
...
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com >
2019-11-22 12:04:49 +01:00
pancho horrillo
8474f31747
doc: update request_life_cycle.rst
2019-11-22 09:20:29 +01:00
pancho horrillo and Roberto Abdelkader Martínez Pérez
24cc530a0e
doc: add missing quotes in example
...
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com >
2019-11-21 13:12:19 +01:00
pancho horrillo
8f876ba7db
doc: fix a couple of typos and drop spurious whitespace
2019-11-21 10:36:46 +01:00
pancho horrillo and Roberto Abdelkader Martínez Pérez
ae0c8b58a1
Misc doc updates
...
Co-Authored-By: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com >
2019-11-20 16:37:00 +01:00
pancho horrillo
25d9f1c1ef
Delete placeholder
2019-11-20 16:16:32 +01:00
pancho horrillo
e5e8da551e
docs/philosophy.rst: style fixes
2019-11-20 14:30:28 +01:00
pancho horrillo and Roberto Abdelkader Martínez Pérez
5ee8353cba
WIP on docs/theory
...
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com >
2019-11-20 12:54:29 +01:00
pancho horrillo
206aac5747
Rename package srverrors to httperror
...
- Package names are preferred to be in singular form¹.
- Since errors are just for HTTP and not generic, I changed the base name to
'http'.
- I didn't name it simply 'error', because it would then conflict with the
- standard 'error' interface.
¹: https://rakyll.org/style-packages/
2019-11-20 07:54:45 +01:00
pancho horrillo
0d66fe9963
Rename WriteErrorResponse() to simply ErrorJSON() and reorder arguments
...
This way we better mimic net/http.Error()
https://pkg.go.dev/net/http?tab=doc#Error
2019-11-20 07:37:35 +01:00
pancho horrillo
7ea43048bc
Add missing comments
2019-11-20 07:14:00 +01:00
pancho horrillo
d81ef278da
Update Makefile to make use of -trimpath build option
...
This option makes go build/install removes the absolute paths
within the produced executable, enabling more reproducible builds.
See ¹ for more details.
¹: https://golang.org/doc/go1.13?ref=hvper.com#go-command
2019-11-20 06:43:40 +01:00
pancho horrillo
75b0908b16
Rename GetReasonFromBody() to simply Reason()
...
See ¹ for the customary idiomatic way of naming getters in Go.
¹: https://golang.org/doc/effective_go.html#Getters
2019-11-20 05:04:10 +01:00
pancho horrillo
3a47b34bc1
Drop stale GetReason() and associated tests
2019-11-20 04:54:07 +01:00
pancho horrillo
b40f73115f
Add missing comment to GetReasonFromBody()
2019-11-20 04:51:29 +01:00
pancho horrillo
b130cfdec7
Add some examples
...
Note that the example on redirecting a URL is BROKEN. Possibly a bug in Kapow!
2019-11-19 21:52:10 +01:00
pancho horrillo
81c677c3be
internal/http/request.go: replace GetReason() with GetReasonFromBody()
...
Update tests to inject the required JSON error body with reason.
2019-11-19 21:17:49 +01:00
pancho horrillo
e7619238ae
Add GetReasonFromBody() that extracts reason from JSON
2019-11-19 21:17:34 +01:00
pancho horrillo
28f4b969f9
Update go.{mod,sum} recreating them from scratch
...
$ rm go.{mod,sum}; go mod init github.com/BBVA/kapow
go: creating new go.mod: module github.com/BBVA/kapow
$ go mod tidy -v
go: finding github.com/google/shlex latest
With this, we've gotten rid an unneeded dep (github.com/spf13/pflag @ v1.0.5).
2019-11-19 17:50:16 +01:00
pancho horrillo
806905c49c
Update go.{mod,sum}
...
Set base version to go 1.13
and run:
$ go mod tidy -v
unused github.com/gogo/protobuf
unused github.com/golangci/gocyclo
unused github.com/golangci/golangci-lint
unused github.com/golangci/revgrep
unused github.com/gostaticanalysis/analysisutil
unused github.com/konsorten/go-windows-terminal-sequences
unused github.com/magiconair/properties
unused github.com/mattn/go-isatty
unused github.com/pelletier/go-toml
unused github.com/securego/gosec
unused github.com/spf13/afero
unused github.com/spf13/jwalterweatherman
unused github.com/uudashr/gocognit
unused golang.org/x/sys
unused golang.org/x/tools
unused mvdan.cc/unparam
unused sourcegraph.com/sqs/pbtypes
2019-11-19 17:32:28 +01:00
pancho horrillo
83e4523dc7
Simplify files via gofmt -s (thanks, Go Report Card!)
2019-11-19 14:14:55 +01:00
pancho horrillo
92fbb72735
Fix typos catched via misspell (thanks Go Report Card!)
2019-11-19 14:07:58 +01:00
pancho horrillo
1249b23458
Fix case mismatch in error JSON (adding tag)
2019-11-18 17:44:39 +01:00
pancho horrillo
402bbf00d7
Fix style in comment
2019-11-15 21:00:21 +01:00
pancho horrillo and Roberto Abdelkader Martínez Pérez
3af5def406
poc: make error_body(reason) return a JSON with extraneous fields
...
We then ensure that the cucumber steps only test the
presence of the required fields, not just comparing it byte-wise.
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com >
2019-11-14 17:40:47 +01:00
03de51e6ca
Fix missing quotes in step
...
Co-authored-by: César Gallego Rodríguez <cesar.gallego.next@bbva.com >
Co-Authored-By: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com >
2019-11-14 17:13:34 +01:00
pancho horrillo
9ebc989bc7
poc/Makefile: add 'fix' target (mirroring spec/Makefile)
2019-11-14 17:53:32 +01:00
pancho horrillo and Roberto Abdelkader Martínez Pérez
3e2bc44c0b
spec/Makefile: on fix target, skip tagged scenarios and features
...
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com >
2019-11-14 17:53:02 +01:00
pancho horrillo
f43e47f4f1
Remove leftover script
2019-11-14 11:57:44 +01:00
pancho horrillo
2d5743af84
Add blank line between legal header and package declaration
...
Otherwise, the legal header is rendered as package documentation.
2019-11-13 18:18:44 +01:00
pancho horrillo and Roberto Abdelkader Martínez Pérez
822e4f85df
spec: clarify the order of the execution of the tests
...
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com >
2019-11-11 18:02:07 +01:00
pancho horrillo and Roberto Abdelkader Martínez Pérez
6194c6961a
Tweak PoC to pass current test suite
...
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com >
2019-11-11 17:47:28 +01:00
pancho horrillo and Roberto Abdelkader Martínez Pérez
e4606ab84a
Drop compound error scenario
...
In order to allow different Kapow! implementations (Go, Python, ...)
compound errors will be left as implementation-dependent.
The spec will only test for simple error conditions.
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com >
2019-11-11 17:47:28 +01:00
pancho horrillo and Roberto Abdelkader Martínez Pérez
9eb186bd0f
Revert "Closes: #66 "
...
This reverts commit c3be29255a .
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com >
2019-11-11 17:47:20 +01:00
pancho horrillo
fe303d4d02
README.rst: Fix heading
2019-11-03 23:39:21 +01:00
pancho horrillo
28f0ae03d5
doc: misc fixes and tweaks
...
* doc/README.md:
- Fix a couple of typos.
- Fix spacing and shell quote style (for consistency with other markdown docs
already in the tree).
- Fix indent with spaces not tabs in heredocs with <<- style¹.
- Fix shell example partially inserted twice.
* doc/*.pow:
- Fix indent with spaces not tabs in heredocs with <<- style¹.
¹: See the last paragraph in
https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Here-Documents
"If the redirection operator is ‘<<-’, then all leading tab characters
are stripped from input lines and the line containing delimiter. This allows
here-documents within shell scripts to be indented in a natural fashion."
2019-10-31 18:49:48 +01:00
pancho horrillo
0639b3af50
spec: add missing empty line
2019-10-31 18:45:48 +01:00
pancho horrillo
d5e9ab0f07
spec: add missing space after full-stop.
...
Mostly to trigger a Circle CI rebuild.
2019-10-30 17:58:05 +01:00
pancho horrillo
e413ce4805
Drop now-spurious env var setting in call to behave at Circle CI config
2019-10-30 17:43:14 +01:00
pancho horrillo
c3180e3e7d
spec: fix incorrect default value for KAPOW_DATAAPI_URL
...
This caused ghost failures when running the tests.
2019-10-30 17:40:40 +01:00
pancho horrillo
275db5ef91
spec: add entry on KAPOW_USER_URL env var
2019-10-30 17:40:40 +01:00
pancho horrillo
604a6d7d4d
spec: add entry on KAPOW_BOOT_TIMEOUT env var
2019-10-30 17:40:33 +01:00
pancho horrillo and Héctor Hurtado
712d26db89
Tweak Circle CI config not to run skipped tests
...
Co-authored-by: Héctor Hurtado <hector.hurtado@bbva.com >
2019-10-29 15:18:58 +01:00
pancho horrillo
3dd038e0aa
Revert nmap examples, they need more work
...
Closes : #65
2019-10-28 16:46:02 +01:00
pancho horrillo
00770650a8
Rename nmap example to nmap-web
...
* Drop unused CSS section
2019-10-25 19:21:04 +02:00
pancho horrillo
c29a17d7e4
Fix handling of arguments
...
Closes : #67
2019-10-25 18:54:52 +02:00
pancho horrillo
56876335b7
Add yet another Nmap example, ideal to be consumed by browser
...
I intend to replace the nmap-streaming.pow example with this one.
I've realized that nmap-streaming.pow is not actually a streaming example,
since Nmap won't write its output(s) until scan is finished, and hence, kapow
will serve them in one shot.
Check it out, @nilp0inter, @cr0hn.
2019-10-25 08:14:38 +02:00
pancho horrillo
2fc18b76e3
poc/examples/nmap-{streaming,callback}.pow: minor cleanup
...
* Update comments.
* Add Content-Type: text/xml header (nmap-streaming.pow) only.
* Wrap the Nmap output in XML comment delimiters, *after* the XML header.
* Write to /response/body (preferred) instead of /response/stream (legacy).
* Use suffix .xml for temp files.
* Move possibly noise-generating calls outside of the block
that is sent to the /request/body.
2019-10-24 17:05:54 +02:00
pancho horrillo and César Gallego Rodríguez
b0c16ca684
Validate url_pattern format in control API append operation
...
Closes : #38
Co-authored-by: César Gallego Rodríguez <cesar.gallego.next@bbva.com >
2019-10-24 14:10:58 +02:00
pancho horrillo
d2c3138036
Give nmap examples some lovin'.
...
* Add legal headers.
* Add default values for params and forms.
* Cleanup code a bit.
* Wrap nmap output in XML comments; not legal, but perhaps better than the alternative.
2019-10-24 07:27:20 +02:00
pancho horrillo
52ae3375a4
Drop stale TODO comment
...
Close #42
2019-10-23 18:52:20 +02:00
pancho horrillo
ae3bd76434
Leverage ioutil.ReadAll() and ioutil.ReadFile() to simplify logic
...
Related to: #46
2019-10-23 18:01:58 +02:00
pancho horrillo
7674725658
Drop TODO line of solved issue
...
Related to #46
2019-10-23 17:59:37 +02:00
pancho horrillo and Roberto Abdelkader Martínez Pérez
034a5ab677
Fix typo in comment
...
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com >
2019-10-22 16:29:54 +02:00
pancho horrillo
5bbc341e10
Update internal/cmd/server.go
...
- Honour --bind, --control-bind, --data-bind
- Drop unused params (--interactive, --url, --control-url, --data-url)
- Minimize environment for running the powfile shell script
- Drop debug code
TODO: actual key and cert handling for https
2019-10-20 18:39:50 +02:00
pancho horrillo
341768ace8
internal/cmd/server.go: sort imports
2019-10-20 18:38:29 +02:00
pancho horrillo
bb5843ec35
Fix lowercase ID in human-readable messages
2019-10-20 18:32:46 +02:00
pancho horrillo
d31165c82f
Drop trailing slash in URL to query routes
...
This one slipped through the tests, I think because the automagic handling of
trailing slashes by the net/http muxer.
With it, the command:
$ kapow route list
fails with a 'Not Found'.
2019-10-20 18:20:46 +02:00
pancho horrillo and César Gallego
b14ea93a64
Minor fixes on error handling
...
Co-authored-by: César Gallego <gallego.cesar@gmail.com >
2019-10-17 17:11:19 +02:00
pancho horrillo and César Gallego
ee00a7bccc
Fix param names to use the right URL
...
Co-authored-by: César Gallego <gallego.cesar@gmail.com >
2019-10-17 17:04:59 +02:00
pancho horrillo and César Gallego
4638bec5fe
Gather binding vars for each server and run them
...
Co-authored-by: César Gallego <gallego.cesar@gmail.com >
2019-10-17 17:03:45 +02:00
pancho horrillo and César Gallego
81cbea4ff8
Fix method used in client.AddRoute()
...
Co-authored-by: César Gallego <gallego.cesar@gmail.com >
2019-10-17 16:58:38 +02:00
pancho horrillo
b4f2e9ffdd
Refactor tests
...
* Get rid of spurious model.Route{} var, by adding content
directly into model.Handler{} literal.
* Adjust spacing to adhere to the prepare-call-test test structure.
2019-10-13 08:17:16 +02:00
pancho horrillo
c62a0d6a9a
Sort imports intro three blocks (stdlib, non-stdlib, current prj)
2019-10-13 08:09:15 +02:00
pancho horrillo and Roberto Abdelkader Martínez Pérez
df5d38e94f
swappableMux is now public and Append() now updates Server.Handler
...
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com >
2019-10-10 20:22:09 +02:00
pancho horrillo and Roberto Abdelkader Martínez Pérez
b4dd6e9805
Add New() func & Update() method to internal/server/user/mux/swappableMux
...
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com >
2019-10-10 19:26:17 +02:00
pancho horrillo and Roberto Abdelkader Martínez Pérez
463382bfb2
Add internal/server/user/mux/handlerbuilder{,_test}.go
...
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com >
2019-10-10 18:16:15 +02:00
pancho horrillo and Roberto Abdelkader Martínez Pérez
2129c4a1f6
internal/server/model.Handler.Route is no longer a pointer
...
Also Spawn() now checks if entrypoint is not set
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com >
2019-10-10 18:16:15 +02:00
pancho horrillo and Roberto Abdelkader Martínez Pérez
b76fb1f77e
Add method ListIDs() to internal/data/Handlers
...
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com >
2019-10-10 13:11:05 +02:00
pancho horrillo and Roberto Abdelkader Martínez Pérez
a39e0f6605
Spawner ready
...
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com >
2019-10-10 11:49:58 +02:00
pancho horrillo and Roberto Abdelkader Martínez Pérez
d0764f07a4
First cut to spawner
...
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com >
2019-10-09 18:28:33 +02:00
pancho horrillo and Roberto Abdelkader Martínez Pérez
fa8cc271dc
Build jaillover via Makefile
...
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com >
2019-10-09 16:25:04 +02:00
pancho horrillo and Roberto Abdelkader Martínez Pérez
273058c3ba
Add testutils/jaillover to assist testing process spawning
...
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com >
2019-10-09 16:17:21 +02:00
pancho horrillo and Roberto Abdelkader Martínez Pérez
49252a78a6
Fix misuse of gorilla/mux.Router{} use mux.NewRouter() instead
...
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com >
2019-10-09 15:22:50 +02:00
pancho horrillo and Roberto Abdelkader Martínez Pérez
401644b65e
Finish gorillize()
...
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com >
2019-10-09 13:10:04 +02:00
pancho horrillo and Roberto Abdelkader Martínez Pérez
2cd96d5a4b
Add the controversial gorillize()
...
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com >
2019-10-08 19:39:44 +02:00
pancho horrillo and Roberto Abdelkader Martínez Pérez
037347dbe3
Augment safeRouteList.Append() to return a model.Route with index
...
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com >
2019-10-08 17:53:15 +02:00
pancho horrillo and Roberto Abdelkader Martínez Pérez
e0dd6f5dd5
Refactor internal/server/user package structure
...
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com >
2019-10-08 17:22:09 +02:00
pancho horrillo and Roberto Abdelkader Martínez Pérez
2eb32610a0
Exclude test from race condition verification
...
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com >
2019-10-08 15:34:42 +02:00
9ad61249b3
Fix linter warning
...
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com >
Co-authored-by: Héctor Hurtado <hector.hurtado@bbva.com >
2019-10-08 15:33:32 +02:00
pancho horrillo and Roberto Abdelkader Martínez Pérez
3b405bd9f6
Add ServeHTTP() method to swappableMux struct
...
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com >
2019-10-08 15:06:08 +02:00
pancho horrillo
0cab49f082
Simplify handling of http.Client response
...
As per the doc¹:
If the returned error is nil, the Response will contain a non-nil Body which the user is expected to close.
...
On error, any Response can be ignored. A non-nil Response with a non-nil error
only occurs when CheckRedirect fails, and even then the returned Response.Body
is already closed.
It is thus safe to defer res.Body.Close() as soon as err has been determined to
be nil.
Also, I've dispensed with the separate variable client, since it is not used
later.
¹: https://godoc.org/net/http#Client.Do
2019-10-08 05:42:33 +02:00
pancho horrillo
7ba54b32b3
Revert to using strings for simplicity
...
It is safe in this case.
* gock.BodyString(body string) coerces body into a []byte
* client.SetData() eventually resolves to a call to http.Client.Do(), which
handles the string gracefully as well.
2019-10-08 05:28:29 +02:00
pancho horrillo and Roberto Abdelkader Martínez Pérez
10586bae95
Add internal/server/user/server{,_test}.go
...
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com >
2019-10-07 19:05:59 +02:00
pancho horrillo
0b056f6cf0
internal/client/{get,set}_test.go: send io.Writer() based on []byte
...
* internal/client/get_test.go:
- Revert changes when setting the Body of the mock (gock).
- Revert over-eager line splitting.
* internal/client/set_test.go:
- Use bytes.NewReader([]byte("200")) instead of strings.NewReader("200")
Thanks to @nilp0inter for the feedback!
2019-10-06 11:34:15 +02:00
pancho horrillo
f98784088d
Normalize internal/client/*_test.go
...
* Adjust test style for easy reading, by using literals instead of vars
* Move comparison to the `bytes` domain, instead of `string`
* Simplify testing code by using bytes.Buffer directly
* More consistent naming of variables and dummies (HANDLE_{FOO,BAR,BAD})
* Consistent testing style of gock.IsDone()
* Stick to 80-column
2019-10-06 09:41:12 +02:00
pancho horrillo
6154210b3f
Update PoC and features with the 204 -> 404 update
...
Closes #33
2019-10-04 17:24:27 +02:00
pancho horrillo and Héctor Hurtado
a865ade26a
Use string concatenation to compose simple expression
...
Co-authored-by: Héctor Hurtado <hector.hurtado@bbva.com >
2019-10-04 07:28:08 +02:00
pancho horrillo and Héctor Hurtado
57d1aabb66
internal/cmd/route.go: replace dummies with calls to client code
...
Co-authored-by: Héctor Hurtado <hector.hurtado@bbva.com >
2019-10-04 06:46:40 +02:00