Skip to content

Commit

Permalink
Merge pull request #6 from 1Password/release/v1.0.1
Browse files Browse the repository at this point in the history
Prepare Release - v1.0.1
  • Loading branch information
ag-griffin authored Apr 9, 2021
2 parents 5b34fc9 + 6fec3fe commit 3e9a5be
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@

---

[//]: # "START/v1.0.1"

# v1.0.1

## Fixes

- Includes the correct version number in the user agent when making requests

---

[//]: # "START/v1.0.0"

# v1.0.0
Expand Down
4 changes: 2 additions & 2 deletions connect/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

const (
defaultUserAgent = "connect-sdk-go/0.0.1"
defaultUserAgent = "connect-sdk-go/%s"
)

// Client Represents an available 1Password Connect API to connect to
Expand Down Expand Up @@ -61,7 +61,7 @@ func NewClientFromEnvironment() (Client, error) {

// NewClient Returns a Secret Service client for a given url and jwt
func NewClient(url string, token string) Client {
return NewClientWithUserAgent(url, token, defaultUserAgent)
return NewClientWithUserAgent(url, token, fmt.Sprintf(defaultUserAgent, SDKVersion))
}

// NewClientWithUserAgent Returns a Secret Service client for a given url and jwt and identifies with userAgent
Expand Down
12 changes: 7 additions & 5 deletions connect/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var testClient *restClient

var requestCount int
var requestFail bool
var testUserAgent string

type mockClient struct {
Dofunc func(req *http.Request) (*http.Response, error)
Expand All @@ -37,6 +38,7 @@ func TestMain(m *testing.M) {
validHost = "http://localhost:8080"
validToken = "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyIxcGFzc3dvcmQuY29tL2F1dWlkIjoiR1RLVjVWUk5UUkVHUEVMWE41QlBSQTJHTjQiLCIxcGFzc3dvcmQuY29tL2Z0cyI6WyJ2YXVsdGFjY2VzcyJdLCIxcGFzc3dvcmQuY29tL3Rva2VuIjoidTFxMUNtWVhtbGR2YWZUa0lHTW8tLTJnazl5a180SkMiLCIxcGFzc3dvcmQuY29tL3Z0cyI6W3siYSI6MTU3MzA2NzIsInUiOiJvdGw2cjZudWdqNXdyNjNybmt3M3Y0cGJuYSJ9XSwiYXVkIjpbImNvbS4xcGFzc3dvcmQuc2VjcmV0c2VydmljZSJdLCJpYXQiOjE2MDMxMjg2NDIsImlzcyI6ImNvbS4xcGFzc3dvcmQuYjUiLCJqdGkiOiI2bjYyZHhyanBxZW00aGJ4d3dxdGJtNmpsZSIsInN1YiI6IkFWNFFORUM3UFJGREZFRTJJREpNM0NSSUNJIn0.-1shD95-qGYrHh3beH5nrfsV91BMp30Y9ipIwE6n4pw8Y9-2fR-gun27ShS9fHLJqW9xJZ-Eir1UEkiha2ucvA"
defaultVault = "otl6r6nugj5wr63rnkw3v4pbna"
testUserAgent = fmt.Sprintf(defaultUserAgent, SDKVersion)

os.Setenv("OP_VAULT", defaultVault)
os.Setenv("OP_CONNECT_HOST", validHost)
Expand All @@ -47,7 +49,7 @@ func TestMain(m *testing.M) {
testClient = &restClient{
URL: validHost,
Token: validToken,
userAgent: defaultUserAgent,
userAgent: testUserAgent,
tracer: opentracing.GlobalTracer(),
client: mockHTTPClient,
}
Expand Down Expand Up @@ -101,8 +103,8 @@ func TestNewClientFromEnvironment(t *testing.T) {
t.FailNow()
}

if restClient.userAgent != defaultUserAgent {
t.Logf("Expected user-agent of %q, got %q", defaultUserAgent, restClient.userAgent)
if restClient.userAgent != testUserAgent {
t.Logf("Expected user-agent of %q, got %q", testUserAgent, restClient.userAgent)
t.FailNow()
}
}
Expand All @@ -126,8 +128,8 @@ func TestNewClient(t *testing.T) {
t.FailNow()
}

if restClient.userAgent != defaultUserAgent {
t.Logf("Expected user-agent of %q, got %q", defaultUserAgent, restClient.userAgent)
if restClient.userAgent != testUserAgent {
t.Logf("Expected user-agent of %q, got %q", testUserAgent, restClient.userAgent)
t.FailNow()
}
}
Expand Down
2 changes: 1 addition & 1 deletion connect/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package connect

// SDKVersion is the latest Semantic Version of the library
// Do not rename this variable without changing the regex in the Makefile
const SDKVersion = "1.0.0"
const SDKVersion = "1.0.1"

0 comments on commit 3e9a5be

Please sign in to comment.