-
Notifications
You must be signed in to change notification settings - Fork 10
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
Small Status List Updates #95
base: main
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## main #95 +/- ##
==========================================
+ Coverage 69.92% 70.97% +1.05%
==========================================
Files 21 21
Lines 1197 1199 +2
Branches 135 135
==========================================
+ Hits 837 851 +14
+ Misses 292 281 -11
+ Partials 68 67 -1
|
if (response.status.isSuccess()) { | ||
val body = response.bodyAsText() | ||
return VerifiableCredential.parseJwt(body) | ||
} else { | ||
throw ClientRequestException(response, "Failed to retrieve VerifiableCredentialType from $url") | ||
throw ClientRequestException( |
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.
Throwing inside a try
block seems like a code smell to me. Is that intentional?
@@ -361,7 +395,7 @@ class StatusListCredentialTest { | |||
} | |||
|
|||
@Test | |||
fun `should asynchronously validate if a credential is in the status list using a mock HTTP client`() = runBlocking { | |||
fun `should asynchronously validate if a credential is in the status list using a mock HTTP client`() { |
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.
can you explain the "asynchronously" here @nitro-neal ?
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.
has to make an http GET to download the status list credential (vs passing in the status list credential object)
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 was also confused by this. Asynchronously, to me, means that you would need to explicitly wait until the http GET downloads the credential. That doesn't seem to be what the test is doing. Furthermore, that implementation has a runBlocking
bit, which actually makes the async call be blocking.
My suggestion is to rename to should validate if a credential is in the status list using a mock HTTP client
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 good. There's a number of lines that aren't covered by tests. Would it make sense to expand the tests so that they're covered?
} | ||
|
||
require(response.status.isSuccess()) { | ||
"Failed to retrieve VerifiableCredentialType from $url with status ${response.status}" |
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.
This throws an IllegalArgumentException. Is that what you intended?
"Failed to retrieve VerifiableCredentialType from $url with status ${response.status}" | ||
} | ||
|
||
try { |
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 wonder if this try/catch block could be removed to simplify the code.
|
||
if (!duplicateSet.add(statusListEntry.statusListIndex)) { | ||
throw IllegalArgumentException("duplicate entry found with index: ${statusListEntry.statusListIndex}") | ||
throw IllegalArgumentException("Duplicate entry found with index: ${statusListEntry.statusListIndex}") |
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.
throw IllegalArgumentException("Duplicate entry found with index: ${statusListEntry.statusListIndex}") | |
"Duplicate entry found with index: ${statusListEntry.statusListIndex}" |
@@ -361,7 +395,7 @@ class StatusListCredentialTest { | |||
} | |||
|
|||
@Test | |||
fun `should asynchronously validate if a credential is in the status list using a mock HTTP client`() = runBlocking { | |||
fun `should asynchronously validate if a credential is in the status list using a mock HTTP client`() { |
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 was also confused by this. Asynchronously, to me, means that you would need to explicitly wait until the http GET downloads the credential. That doesn't seem to be what the test is doing. Furthermore, that implementation has a runBlocking
bit, which actually makes the async call be blocking.
My suggestion is to rename to should validate if a credential is in the status list using a mock HTTP client
Small updates to cred status list impl