Skip to content

Commit

Permalink
Rename DecodePayload to DecodeB64Payload
Browse files Browse the repository at this point in the history
  • Loading branch information
ethan-lowman-dd committed Apr 12, 2022
1 parent 77f2aec commit f258f0c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions dsse/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ type Envelope struct {
}

/*
DecodePayload returns the serialized body, decoded
DecodeB64Payload returns the serialized body, decoded
from the envelope's payload field. A flexible
decoder is used, first trying standard base64, then
URL-encoded base64.
*/
func (e *Envelope) DecodePayload() ([]byte, error) {
func (e *Envelope) DecodeB64Payload() ([]byte, error) {
return b64Decode(e.Payload)
}

Expand Down
10 changes: 5 additions & 5 deletions dsse/sign_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ func TestEcdsaSign(t *testing.T) {
assert.Equal(t, acceptedKeys[0].KeyID, keyID, "unexpected keyid")
}

func TestDecodePayload(t *testing.T) {
func TestDecodeB64Payload(t *testing.T) {
var want = make([]byte, 256)
for i := range want {
want[i] = byte(i)
Expand All @@ -345,15 +345,15 @@ func TestDecodePayload(t *testing.T) {
env := &Envelope{
Payload: b64Std,
}
got, err := env.DecodePayload()
got, err := env.DecodeB64Payload()
assert.Nil(t, err, "unexpected error")
assert.Equal(t, want, got, "wrong data")
})
t.Run("URL encoding", func(t *testing.T) {
env := &Envelope{
Payload: b64Url,
}
got, err := env.DecodePayload()
got, err := env.DecodeB64Payload()
assert.Nil(t, err, "unexpected error")
assert.Equal(t, want, got, "wrong data")
})
Expand All @@ -362,15 +362,15 @@ func TestDecodePayload(t *testing.T) {
env := &Envelope{
Payload: b64StdErr,
}
got, err := env.DecodePayload()
got, err := env.DecodeB64Payload()
assert.NotNil(t, err, "expected error")
assert.Nil(t, got, "wrong data")
})
t.Run("URL encoding - error", func(t *testing.T) {
env := &Envelope{
Payload: b64UrlErr,
}
got, err := env.DecodePayload()
got, err := env.DecodeB64Payload()
assert.NotNil(t, err, "expected error")
assert.Nil(t, got, "wrong data")
})
Expand Down
2 changes: 1 addition & 1 deletion dsse/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (ev *EnvelopeVerifier) Verify(e *Envelope) ([]AcceptedKey, error) {
}

// Decode payload (i.e serialized body)
body, err := e.DecodePayload()
body, err := e.DecodeB64Payload()
if err != nil {
return nil, err
}
Expand Down

0 comments on commit f258f0c

Please sign in to comment.