Skip to content

Commit 0e888d6

Browse files
committed
grant json should use lowercase field names
Signed-off-by: Gregory Hill <[email protected]>
1 parent ec578c6 commit 0e888d6

File tree

14 files changed

+2614
-232
lines changed

14 files changed

+2614
-232
lines changed

Diff for: CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# [Monax Hoard](https://github.com/monax/hoard) Changelog
2+
## [8.2.0] - 2020-03-20
3+
### Changed
4+
- Grant json now uses lowercase field names for compatability with client lib
5+
6+
27
## [8.1.0] - 2020-03-09
38
### Changed
49
- Header now specifies arbitrary data payload
@@ -182,6 +187,7 @@ This is the first Hoard open source release and includes:
182187
- Hoar-Daemon hoard
183188
- Hoar-Control hoarctl CLI
184189

190+
[8.2.0]: https://github.com/monax/hoard/compare/v8.1.0...v8.2.0
185191
[8.1.0]: https://github.com/monax/hoard/compare/v8.0.2...v8.1.0
186192
[8.0.2]: https://github.com/monax/hoard/compare/v8.0.1...v8.0.2
187193
[8.0.1]: https://github.com/monax/hoard/compare/v8.0.0...v8.0.1

Diff for: NOTES.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
### Changed
2-
- Header now specifies arbitrary data payload
2+
- Grant json now uses lowercase field names for compatability with client lib
33

Diff for: grant/grant.pb.go

+33-27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: grant/grant_test.go

+12
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package grant
22

33
import (
44
"encoding/base64"
5+
"encoding/json"
56
"io/ioutil"
67
"strings"
78
"testing"
@@ -139,3 +140,14 @@ func deriveSecret(t *testing.T, data []byte) []byte {
139140
assert.NoError(t, err)
140141
return secret
141142
}
143+
144+
func TestUnmarshal(t *testing.T) {
145+
// the client library stores the grant with lowercase field names,
146+
// we expect the go server to correctly unmarshal this
147+
data := `{"spec":{"plaintext":{},"symmetric":null,"openpgp":null},"encryptedreferences":"eyJSZWZzIjpbeyJBZGRyZXNzIjoidDIzZjh1cTZsd3lJL2ZTTGJaMVJ2b3ZMYzFSSDMwWEk4cUlyUzBQZnljOD0iLCJTZWNyZXRLZXkiOiI0N0RFUXBqOEhCU2ErL1RJbVcrNUpDZXVRZVJrbTVOTXBKV1pHM2hTdUZVPSIsIlZlcnNpb24iOjF9LHsiQWRkcmVzcyI6Ii8rdWxUa0N6cFlnMnNQYVp0cVM4ZHljSkJMWTkzODd5WlBzdDhMWDVZTDA9IiwiU2VjcmV0S2V5IjoidGJ1ZGdCU2crYkhXSGlIbmx0ZU56TjhUVXZJODB5Z1M5SVVMaDRya2xFdz0ifV19","version":2}`
148+
grant := new(Grant)
149+
err := json.Unmarshal([]byte(data), grant)
150+
require.NoError(t, err)
151+
require.Equal(t, int32(2), grant.GetVersion())
152+
require.NotNil(t, grant.GetSpec().GetPlaintext())
153+
}

0 commit comments

Comments
 (0)