-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade dependencies #65
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SetAuthToken method returns an error, which needs to be handled in a few places.
@@ -106,17 +106,21 @@ func TestDatasetPermissionsRequestBuilder_NewPermissionsRequest(t *testing.T) { | |||
} | |||
|
|||
req := httptest.NewRequest("GET", testHost, nil) | |||
headers.SetUserAuthToken(req, "111") | |||
headers.SetAuthToken(req, "111") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SetAuthToken returns an error, which is currently unhandled.
@@ -153,17 +161,21 @@ func TestDatasetPermissionsRequestBuilder_NewPermissionsRequest(t *testing.T) { | |||
req := httptest.NewRequest("GET", testHost, nil) | |||
|
|||
headers.SetServiceAuthToken(req, "222") | |||
headers.SetUserAuthToken(req, "333") | |||
headers.SetAuthToken(req, "333") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error needs to be handled here too.
@@ -48,7 +48,7 @@ func TestPermissionsRequestBuilder_NewPermissionsRequest(t *testing.T) { | |||
Convey("should return expected error if error creating new http request", t, func() { | |||
builder := &PermissionsRequestBuilder{Host: "$%^&*(()"} | |||
inboundReq := httptest.NewRequest("GET", testHost, nil) | |||
headers.SetUserAuthToken(inboundReq, "666") | |||
headers.SetAuthToken(inboundReq, "666") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The unhandled error is here too.
@@ -62,7 +62,7 @@ func TestPermissionsRequestBuilder_NewPermissionsRequest(t *testing.T) { | |||
Convey("should return get user permissions request if inbound request contains user auth header", t, func() { | |||
builder := &PermissionsRequestBuilder{Host: testHost} | |||
inboundReq := httptest.NewRequest("GET", testHost, nil) | |||
headers.SetUserAuthToken(inboundReq, "666") | |||
headers.SetAuthToken(inboundReq, "666") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here too.
}) | ||
|
||
Convey("should return get user permissions request if inbound request contains both user and service auth headers", t, func() { | ||
builder := &PermissionsRequestBuilder{Host: testHost} | ||
inboundReq := httptest.NewRequest("GET", testHost, nil) | ||
headers.SetServiceAuthToken(inboundReq, "666") | ||
headers.SetUserAuthToken(inboundReq, "777") | ||
headers.SetAuthToken(inboundReq, "777") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And also here.
Hi @cookel2 , the files you refer to are unit tests and handling the errors there would be pointless as those are not the functions in test but only setting pre requisites. It would make the test more difficult to read without adding any value - if if failed, the test would fail anyway. Plus it is not new code and that was present before this change. |
Upgrade dependencies.
Move to dp-api-clients v2 whose
headers.SetAuthToken
not only sets theX-Florence-Token
header but also theAuthorization
header (see https://github.com/ONSdigital/dp-api-clients-go/blob/6cf6846c101baca1a39cf1e7a5726578e97ec964/headers/headers.go#L209-L224), hence amending unit tests