Skip to content
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

Merged
merged 1 commit into from
Apr 25, 2023
Merged

Upgrade dependencies #65

merged 1 commit into from
Apr 25, 2023

Conversation

rafahop
Copy link
Contributor

@rafahop rafahop commented Apr 25, 2023

Upgrade dependencies.

Move to dp-api-clients v2 whose headers.SetAuthToken not only sets the X-Florence-Token header but also the Authorization header (see https://github.com/ONSdigital/dp-api-clients-go/blob/6cf6846c101baca1a39cf1e7a5726578e97ec964/headers/headers.go#L209-L224), hence amending unit tests

Copy link
Contributor

@cookel2 cookel2 left a 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")
Copy link
Contributor

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")
Copy link
Contributor

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")
Copy link
Contributor

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")
Copy link
Contributor

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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And also here.

@rafahop
Copy link
Contributor Author

rafahop commented Apr 25, 2023

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.

@cookel2 cookel2 self-requested a review April 25, 2023 15:16
@rafahop rafahop merged commit be3a9d0 into v1 Apr 25, 2023
@rafahop rafahop deleted the bump-v1-libs branch April 25, 2023 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants