Skip to content

Commit

Permalink
feat: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
james-d-elliott committed Jun 10, 2024
1 parent affd146 commit 9eaa24e
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion metadata/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (d *Decoder) Parse(payload *PayloadJSON) (metadata *Metadata, err error) {
}

if n := len(metadata.Unparsed); n != 0 && !d.ignoreEntryParsingErrors {
return metadata, fmt.Errorf("error occured parsing metadata: %d entries had errors during parsing", n)
return metadata, fmt.Errorf("error occurred parsing metadata: %d entries had errors during parsing", n)
}

return metadata, nil
Expand Down
2 changes: 2 additions & 0 deletions metadata/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package metadata handles metadata validation instrumentation.
package metadata
2 changes: 1 addition & 1 deletion metadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ func (j StatementJSON) Parse() (statement Statement, err error) {

if len(j.AaGUID) != 0 {
if aaguid, err = uuid.Parse(j.AaGUID); err != nil {
return statement, fmt.Errorf("error occurred parsing statement with description '%s': error occured parsing AAGUID value: %w", j.Description, err)
return statement, fmt.Errorf("error occurred parsing statement with description '%s': error occurred parsing AAGUID value: %w", j.Description, err)
}
}

Expand Down
5 changes: 2 additions & 3 deletions metadata/providers/cached/doc.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package cached

// The cached package handles a metadata.Provider implementation that both downloads and caches the MDS3 blob. This
// Package cached handles a metadata.Provider implementation that both downloads and caches the MDS3 blob. This
// effectively is the recommended provider in most instances as it's fairly robust. Alternatively we suggest
// implementing a similar provider that leverages the memory.Provider as an underlying element.
//
// This provider only specifically performs updates at the time it's initialized. It has no automatic update
// functionality. This may change in the future however if you want this functionality at this time we recommend making
// your own implementation.
package cached
5 changes: 3 additions & 2 deletions metadata/providers/cached/util.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package cached

import (
"github.com/go-webauthn/webauthn/metadata"
"github.com/go-webauthn/webauthn/metadata/providers/memory"
"io"
"os"

"github.com/go-webauthn/webauthn/metadata"
"github.com/go-webauthn/webauthn/metadata/providers/memory"
)

func doTruncateCopyAndSeekStart(f *os.File, rc io.ReadCloser) (err error) {
Expand Down
5 changes: 2 additions & 3 deletions metadata/providers/memory/doc.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package memory

// The memory package handles a metadata.Provider implementation that solely exists in memory. It's intended as a basis
// Package memory handles a metadata.Provider implementation that solely exists in memory. It's intended as a basis
// for other providers and generally not recommended to use directly unless you're implementing your own logic to handle
// the download and potential caching of the MDS3 blob yourself.
package memory
1 change: 1 addition & 0 deletions metadata/providers/memory/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package memory
import (
"context"
"fmt"

"github.com/google/uuid"

"github.com/go-webauthn/webauthn/metadata"
Expand Down
2 changes: 1 addition & 1 deletion protocol/attestation_tpm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import (
"crypto/x509/pkix"
"encoding/asn1"
"encoding/binary"
"github.com/stretchr/testify/require"
"math/big"
"testing"

"github.com/google/go-tpm/legacy/tpm2"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/go-webauthn/webauthn/protocol/webauthncbor"
"github.com/go-webauthn/webauthn/protocol/webauthncose"
Expand Down
5 changes: 3 additions & 2 deletions protocol/base64_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"strings"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestBase64UnmarshalJSON(t *testing.T) {
Expand Down

0 comments on commit 9eaa24e

Please sign in to comment.