Skip to content

Improve Remote failure error messaging#24

Merged
ps2 merged 2 commits into
ps2:devfrom
gestrich:bugfix/2022-12/bg/remote-error-messaging
Dec 11, 2022
Merged

Improve Remote failure error messaging#24
ps2 merged 2 commits into
ps2:devfrom
gestrich:bugfix/2022-12/bg/remote-error-messaging

Conversation

@gestrich

@gestrich gestrich commented Dec 10, 2022

Copy link
Copy Markdown

See associated Loop PR for high-level info LoopKit/Loop#1867

These changes will update the NigthscoutService to return more detailed descriptions for display.

Screen Shot 2022-12-10 at 3 24 13 PM

Screen Shot 2022-12-10 at 3 24 39 PM

Screen Shot 2022-12-10 at 3 25 11 PM

Screen Shot 2022-12-10 at 3 36 47 PM

guard let password = notification["otp"] as? String else {
return .failure(NotificationValidationError.missingOTP)
}

@gestrich gestrich Dec 10, 2022

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The time the notification was delivered from Nightscout will be presented in a user message for expired OTPs.

@gestrich gestrich force-pushed the bugfix/2022-12/bg/remote-error-messaging branch from 8c563c9 to 60a47b1 Compare December 10, 2022 20:12
@@ -89,30 +89,32 @@ public class OTPManager {
}
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The validation of the OTP was refactored in this class to allow for better error messaging.

guard password.count == passwordDigitCount else {
throw OTPValidationError.invalidFormat(otp: password)
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This will distinguish between a bad password and an expired. That should be helpful for user troubleshooting.

@@ -155,28 +157,62 @@ public class OTPManager {
return Token(name: secretKeyName, issuer: issuerName, generator: generator)
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Refactored this method getLastPasswordsAscending for reuse.

@@ -13,99 +13,131 @@ import XCTest
class OTPManagerTestCase: XCTestCase {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Some test updates and also I refactored the test data modeling to be more flexible as these tests grow.

@gestrich gestrich force-pushed the bugfix/2022-12/bg/remote-error-messaging branch from 60a47b1 to 219faf1 Compare December 10, 2022 20:18
}

}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Several of these methods in this class, and tests, use these structures to wrap up OTPs and their associated valid periods.

@gestrich gestrich marked this pull request as ready for review December 10, 2022 20:21
@gestrich

Copy link
Copy Markdown
Author

@ps2 I've since updated the "OTP" verbiage to use "Password" instead. Just let me know if there is something else preferred.

@ps2 ps2 merged commit a381857 into ps2:dev Dec 11, 2022
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