31 Commits

Author SHA1 Message Date
pancho horrillo
1e63f3c104 feat: Control API uses automatic cross-pinning mTLS (Closes #119)
. kapow server generates on startup a pair of certificates
that will use to secure communications to its control server.
It will communicate the server and client certificates as well
as the client private key to the init programs it launches,
via environment variables.

. kapow server now understands a new flag --control-reachable-addr
which accepts either a IP address or a DNS name, that can be used
to ensure that the generated server certificate will be appropiate
in case the control server must be accessed from something other
than localhost.

Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2021-03-12 17:24:17 +01:00
pancho horrillo
e72c65c859 feat: os-dependent default entrypoint
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2020-12-24 14:03:49 +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
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
52ae3375a4 Drop stale TODO comment
Close #42
2019-10-23 18:52:20 +02:00
Héctor Hurtado
723e4787b3 Added legal header to all Go source files 2019-10-23 13:35:01 +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
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
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
Roberto Abdelkader Martínez Pérez
47bd2be882 Some fixes suggested by golangci-lint 2019-10-07 08:53:48 +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
Roberto Abdelkader Martínez Pérez
4224984e1b Add spacing to comments 2019-10-04 14:18:42 +02:00
Roberto Abdelkader Martínez Pérez
bf88e6a78b Simplify test cases 2019-10-04 14:08:47 +02:00
Héctor Hurtado
6b34047d75 Added gock.IsDone() to route list and remove tests. Remove content type in route remove command. Removed disturbing data for texts. Remove unneeded test in set command. 2019-10-04 13:55:36 +02:00
pancho horrillo
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
b9bf78abf4 Fix route_add{,_test}.go to use an io.Writer for saving the response
Also add a TODO regarding untested response payload.

Co-authored-by: Héctor Hurtado <hector.hurtado@bbva.com>
2019-10-04 06:28:17 +02:00
pancho horrillo
219710bb76 Fix documentation comment
Co-authored-by: Héctor Hurtado <hector.hurtado@bbva.com>
2019-10-04 06:04:56 +02:00
pancho horrillo
c65d2ac548 Don't set MatchType to json in gock for requests without body 2019-10-03 22:50:42 +02:00
pancho horrillo
c01c3db4f9 Fix indentation and drop spurious whitespace 2019-10-03 22:48:21 +02:00
pancho horrillo
df96d322fc Don't set Content-Type to application/json in query without body 2019-10-03 22:47:43 +02:00
pancho horrillo
604569c7a3 Add internal/client/route_list{,_test}.go
Co-authored-by: Héctor Hurtado <hector.hurtado@bbva.com>
2019-10-03 22:42:31 +02:00
Roberto Abdelkader Martínez Pérez
6eb213a545 Adjust set and get to send no Content-Type 2019-10-03 20:57:40 +02:00
Roberto Abdelkader Martínez Pérez
2d712d39dc Adjust current implementation to accomodate content-type and test to check it 2019-10-03 20:56:53 +02:00
Roberto Abdelkader Martínez Pérez
4357b1ad20 Implementation of route add 2019-10-03 20:56:40 +02:00
pancho horrillo
013cd4d637 Add internal/client/route_remove{,_test}.go
Co-authored-by: Héctor Hurtado <hector.hurtado@bbva.com>
2019-10-03 18:22:18 +02:00
pancho horrillo
ffa262b2b6 Simplify internal/client/set.go by leveraging internal/http.Request()
Co-authored-by: Héctor Hurtado <hector.hurtado@bbva.com>
2019-10-03 16:52:15 +02:00
Roberto Abdelkader Martínez Pérez
b1c2db057c Shorthand functions request with common HTTP methods 2019-10-03 15:06:26 +02:00
Roberto Abdelkader Martínez Pérez
681ee3cba8 http becomes an internal package 2019-10-03 14:12:14 +02:00
Roberto Abdelkader Martínez Pérez
d259e3b411 Replace implementation with kapow/http/response 2019-10-03 14:11:06 +02:00
pancho horrillo
23128026c7 Rework directory structure
Co-authored-by: Héctor Hurtado <hector.hurtado@bbva.com>
2019-10-03 12:05:53 +02:00