-
Notifications
You must be signed in to change notification settings - Fork 5
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
Sdk 2246 go retrieve session #282
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.
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 |
Co-authored-by: Iancu Fofiu <[email protected]>
Co-authored-by: Iancu Fofiu <[email protected]>
Co-authored-by: Iancu Fofiu <[email protected]>
Co-authored-by: Iancu Fofiu <[email protected]>
digital_identity_client_test.go
Outdated
Key: key, | ||
} | ||
|
||
_, err := client.GetSession("SOME ID") |
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.
let's add a success test case for this too
digitalidentity/service.go
Outdated
return share, err | ||
} | ||
|
||
response, err := requests.Execute(httpClient, request, ShareSessionHTTPErrorMessages, yotierror.DefaultHTTPErrorMessages) |
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.
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
?
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.
@mehmet-yoti are you still working on this?
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.
Yes I am doing some changes on that.
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.
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
Co-authored-by: Klaidas Urbanavicius <[email protected]>
Co-authored-by: Klaidas Urbanavicius <[email protected]>
Co-authored-by: Klaidas Urbanavicius <[email protected]>
Co-authored-by: Klaidas Urbanavicius <[email protected]>
Co-authored-by: Klaidas Urbanavicius <[email protected]>
Co-authored-by: Klaidas Urbanavicius <[email protected]>
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 |
digitalidentity/service.go
Outdated
@@ -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), |
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.
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?
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.
As read from documentation backend needs this header.
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.
It seems that we don't need it the Params (but we need it in the Headers)
@@ -18,7 +18,7 @@ func ExampleShareSessionNotificationBuilder() { | |||
} | |||
|
|||
fmt.Println(string(data)) | |||
// Output: {"url":"","method":"","verifyTls":null,"headers":null} | |||
// Output: {"url":""} |
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.
maybe here is the point the defaults should have been set?
sonar-project.properties
Outdated
@@ -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/** |
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.
I am not sure this is the right approach. How did the other SDKs solve it?
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.
We should only exclude digitalidentity only from code duplication checks (so use sonar.cpd.exclusions)
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.
see comments
…e the new error format
|
||
func TestDigitalIDClient_GetSession(t *testing.T) { | ||
key, err := os.ReadFile("./test/test-key.pem") | ||
if err != nil { |
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.
looks like the rest of the code in this repo uses assert
package so prob best to be consistent
defaultUnknownErrorCodeConst = "UNKNOWN_ERROR" | ||
defaultUnknownErrorMessageConst = "unknown HTTP error" |
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.
why's the var named ..Const
instead of just being consts?
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.
Just kept the convention from the V1 SDK
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.
that's not a good convention to follow 😆
@@ -0,0 +1,8 @@ | |||
package yotierror | |||
|
|||
const ( |
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.
these aren't used
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.
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.
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.
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 |
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.
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
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.
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.
_examples/idv/handlers.session.go
Outdated
@@ -63,6 +63,7 @@ func pageFromSessionSpec(c *gin.Context, sessionSpec *create.SessionSpecificatio | |||
return | |||
} | |||
createSessionResult, err = client.CreateSession(sessionSpec) | |||
|
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.
we can remove this
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.
Only some minor things left, for me the main one is "use sonar.cpd.exclusions"
Co-authored-by: Klaidas Urbanavicius <[email protected]>
Co-authored-by: Klaidas Urbanavicius <[email protected]>
No description provided.