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

Sdk 2246 go retrieve session #282

Merged
merged 44 commits into from
Oct 15, 2023

Conversation

mehmet-yoti
Copy link
Contributor

No description provided.

Copy link
Contributor

@fofiuiancu fofiuiancu left a comment

Choose a reason for hiding this comment

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

Not covered by this PR but should have been covered by the previous PR:
The ShareSessionRequest should have the optional fields as pointers:
(eg policy is mandatory in Share V2 so it shouldn't be a pointer)

Please see the optional ones here:
https://lampkicking.atlassian.net/wiki/spaces/DAS/pages/3900801110/Share+V2+Payload+documentation

_examples/idv/routes.go Outdated Show resolved Hide resolved
digital_identity_client.go Outdated Show resolved Hide resolved
digital_identity_client.go Outdated Show resolved Hide resolved
digital_identity_client.go Outdated Show resolved Hide resolved
digitalidentity/service.go Outdated Show resolved Hide resolved
digitalidentity/service.go Show resolved Hide resolved
digitalidentity/service.go Outdated Show resolved Hide resolved
digitalidentity/service_test.go Outdated Show resolved Hide resolved
digitalidentity/service_test.go Outdated Show resolved Hide resolved
digitalidentity/service_test.go Outdated Show resolved Hide resolved
@fofiuiancu
Copy link
Contributor

Not covered by this PR but should have been covered by the previous PR: The ShareSessionRequest should have the optional fields as pointers: (eg policy is mandatory in Share V2 so it shouldn't be a pointer)

Please see the optional ones here: https://lampkicking.atlassian.net/wiki/spaces/DAS/pages/3900801110/Share+V2+Payload+documentation

this should also be addressed

digital_identity_client.go Outdated Show resolved Hide resolved
digital_identity_client.go Outdated Show resolved Hide resolved
digital_identity_client_test.go Outdated Show resolved Hide resolved
digitalidentity/service.go Outdated Show resolved Hide resolved
_examples/idv/models.sessionspec.go Outdated Show resolved Hide resolved
digitalidentity/share_session.go Outdated Show resolved Hide resolved
digitalidentity/share_session.go Outdated Show resolved Hide resolved
digitalidentity/share_session_builder.go Show resolved Hide resolved
digitalidentity/service.go Outdated Show resolved Hide resolved
digitalidentity/service_test.go Outdated Show resolved Hide resolved
digital_identity_client.go Show resolved Hide resolved
digital_identity_client.go Outdated Show resolved Hide resolved
Key: key,
}

_, err := client.GetSession("SOME ID")
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's add a success test case for this too

digitalidentity/service.go Outdated Show resolved Hide resolved
digitalidentity/service.go Outdated Show resolved Hide resolved
digitalidentity/service.go Outdated Show resolved Hide resolved
return share, err
}

response, err := requests.Execute(httpClient, request, ShareSessionHTTPErrorMessages, yotierror.DefaultHTTPErrorMessages)
Copy link
Collaborator

Choose a reason for hiding this comment

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

i think we need to update this requests package to support the error codes connect send back, some of these are really useful and we should differentiate between them and give the RP an exported error var they can switch on and handle.

e.g. from looking at this 404 UNKNOWN_SESSION is invalid session id which would be useful for a RP to know when integrating with sdk, as opposed to the ShareSessionHTTPErrorMessages where 404 is mapped to Application was not found?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@mehmet-yoti are you still working on this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I am doing some changes on that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

i don't see the changes for this from the newest commits @mehmet-yoti - feel free to ping me on slack if you wanna chat about it abit quicker

digitalidentity/share_session.go Outdated Show resolved Hide resolved
digitalidentity/share_session.go Outdated Show resolved Hide resolved
digitalidentity/share_session_builder.go Outdated Show resolved Hide resolved
@fofiuiancu
Copy link
Contributor

fofiuiancu commented Oct 6, 2023

Not covered by this PR but should have been covered by the previous PR: The ShareSessionRequest should have the optional fields as pointers: (eg policy is mandatory in Share V2 so it shouldn't be a pointer)
Please see the optional ones here: https://lampkicking.atlassian.net/wiki/spaces/DAS/pages/3900801110/Share+V2+Payload+documentation

this should also be addressed

ShareSessionNotification should also be optional and the Builder should take care of initialising the optionals with defaults where is the case (I a not sure why the extensions is populated in the Builder with an empty array, but haven't investigated it in depth)

It's not clear from the documentation is we should initialise the optionals or if Connect does that if they are not set.

https://lampkicking.atlassian.net/wiki/spaces/DAS/pages/3900801110/Share+V2+Payload+documentation

_examples/idv/handlers.session.go Outdated Show resolved Hide resolved
yotierror/response.go Outdated Show resolved Hide resolved
digital_identity_client_test.go Show resolved Hide resolved
@@ -28,14 +28,16 @@ func CreateShareSession(httpClient requests.HttpClient, shareSessionRequest *Sha
HTTPMethod: http.MethodPost,
BaseURL: apiUrl,
Endpoint: endpoint,
Headers: requests.AuthHeader(clientSdkId),
Headers: requests.AuthHeader(clientSdkId, &key.PublicKey),
Copy link
Contributor

Choose a reason for hiding this comment

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

it seems that we don't need the public key here; do we need the clientSDKId as we're also adding it a few rows later as a Param?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As read from documentation backend needs this header.

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems that we don't need it the Params (but we need it in the Headers)

digitalidentity/share_session_builder.go Outdated Show resolved Hide resolved
@@ -18,7 +18,7 @@ func ExampleShareSessionNotificationBuilder() {
}

fmt.Println(string(data))
// Output: {"url":"","method":"","verifyTls":null,"headers":null}
// Output: {"url":""}
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe here is the point the defaults should have been set?

requests/signed_message.go Outdated Show resolved Hide resolved
@@ -11,4 +11,4 @@ sonar.go.coverage.reportPaths = coverage.out
sonar.go.tests.reportPaths = sonar-report.json
sonar.tests = .
sonar.test.inclusions = **/*_test.go
sonar.coverage.exclusions = test/**/*,_examples/**/*
sonar.coverage.exclusions = test/**/*,_examples/**/*,src/digitalidentity/**
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure this is the right approach. How did the other SDKs solve it?

Copy link
Contributor

Choose a reason for hiding this comment

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

We should only exclude digitalidentity only from code duplication checks (so use sonar.cpd.exclusions)

yotierror/response.go Outdated Show resolved Hide resolved
Copy link
Contributor

@fofiuiancu fofiuiancu left a comment

Choose a reason for hiding this comment

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

see comments


func TestDigitalIDClient_GetSession(t *testing.T) {
key, err := os.ReadFile("./test/test-key.pem")
if err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

looks like the rest of the code in this repo uses assert package so prob best to be consistent

Comment on lines +11 to +12
defaultUnknownErrorCodeConst = "UNKNOWN_ERROR"
defaultUnknownErrorMessageConst = "unknown HTTP error"
Copy link
Collaborator

Choose a reason for hiding this comment

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

why's the var named ..Const instead of just being consts?

Copy link
Contributor

Choose a reason for hiding this comment

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

Just kept the convention from the V1 SDK

Copy link
Collaborator

Choose a reason for hiding this comment

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

that's not a good convention to follow 😆

digitalidentity/yotierror/response.go Show resolved Hide resolved
digitalidentity/yotierror/response.go Outdated Show resolved Hide resolved
yotierror/response.go Outdated Show resolved Hide resolved
digitalidentity/share_session_notification_builder.go Outdated Show resolved Hide resolved
digitalidentity/share_session_builder.go Outdated Show resolved Hide resolved
digitalidentity/service_test.go Outdated Show resolved Hide resolved
@@ -0,0 +1,8 @@
package yotierror

const (
Copy link
Collaborator

Choose a reason for hiding this comment

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

these aren't used

Copy link
Contributor

Choose a reason for hiding this comment

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

True, but this is a package meant to be used by integrators so I;d like to keep them in if we believe they can add value as consts to compare against.

Copy link
Collaborator

Choose a reason for hiding this comment

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

well they would add value if they were used, if they're not used why would they need to compare against them?

@@ -0,0 +1,222 @@
package requests
Copy link
Collaborator

Choose a reason for hiding this comment

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

what was the reason for copying this entire package? it's better to have 1 copy of common code so we can maintain it easier and it won't bite us in the ass if we make a fix to one but forget the copy.

if the whole reason was because we need it to use the new yotierror response to error parsing, we can just version the Execute function like Execute2 or something (or if the name is important like it will be used directly by integrators then we could just have this function by itself inside the digitalidentity package instead) and have that do the new error handling

Copy link
Contributor

Choose a reason for hiding this comment

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

Good points, but, as we plan to retire V1 I thought this version is preferable. That's the same reason the choice was taken to duplicate the Policy code. See the notes here: https://lampkicking.atlassian.net/browse/SDK-2230.

@@ -63,6 +63,7 @@ func pageFromSessionSpec(c *gin.Context, sessionSpec *create.SessionSpecificatio
return
}
createSessionResult, err = client.CreateSession(sessionSpec)

Copy link
Contributor

Choose a reason for hiding this comment

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

we can remove this

Copy link
Contributor

@fofiuiancu fofiuiancu left a comment

Choose a reason for hiding this comment

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

Only some minor things left, for me the main one is "use sonar.cpd.exclusions"

@mehmet-yoti mehmet-yoti changed the base branch from SDK-2240-sharev2-go-create-session to SDK-2230-Expose-share-v2-api October 15, 2023 14:05
@mehmet-yoti mehmet-yoti changed the base branch from SDK-2230-Expose-share-v2-api to SDK-2240-go-create-session October 15, 2023 14:06
@mehmet-yoti mehmet-yoti changed the base branch from SDK-2240-go-create-session to SDK-2230-Expose-share-v2-api October 15, 2023 14:10
@mehmet-yoti mehmet-yoti merged commit caf4d1a into SDK-2230-Expose-share-v2-api Oct 15, 2023
7 checks passed
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.

3 participants