-
Notifications
You must be signed in to change notification settings - Fork 32
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
Username checking in native auth requests #2385
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,8 +96,8 @@ class NativeAuthRequestHandlerTest { | |
) | ||
|
||
// signup start tests | ||
@Test | ||
fun testSignUpStartWithEmptyUsernameShouldNotThrowException() { | ||
@Test(expected = ClientException::class) | ||
fun testSignUpStartWithEmptyUsernameShouldThrowException() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wasn't this changed (i.e. the exception removed) as part of last year's work to align some of our errors and return an InvalidUsernameError in the case of an empty string? Giannis worked on that I believe. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. I think so. But either if (this.status != ICommandResult.ResultStatus.COMPLETED) {
var exception: Exception? = null
var exceptionMessage: String? = ""
if (this.result is Exception) {
exception = this.result as Exception
exceptionMessage = exception.message
}
return com.microsoft.identity.common.java.nativeauth.controllers.results.INativeAuthCommandResult.UnknownError(
error = UNSUCCESSFUL_COMMAND_ERROR,
errorDescription = exceptionMessage,
exception = exception,
correlationId = this.correlationId
) as ExpectedType or return withContext(Dispatchers.IO) {
try {
verifyNoUserIsSignedIn()
if (username.isBlank()) {
return@withContext SignUpError(
errorType = ErrorTypes.INVALID_USERNAME,
errorMessage = "Empty or blank username",
correlationId = "UNSET"
)
} can handle empty username. I think the latter one act the main role of returning InvalidUsernameError before sending out the request/validating request parameters. Thus, I would prefer to keep the ThrowException here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some thoughts:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will abandon this PR. |
||
val commandParameters = SignUpStartCommandParameters.builder() | ||
.platformComponents(mock<PlatformComponents>()) | ||
.username(emptyString) | ||
|
@@ -352,8 +352,8 @@ class NativeAuthRequestHandlerTest { | |
} | ||
|
||
// signin tests | ||
@Test | ||
fun testSignInInitiateWithEmptyUsernameShouldNotThrowException() { | ||
@Test(expected = ClientException::class) | ||
fun testSignInInitiateWithEmptyUsernameShouldThrowException() { | ||
val commandParameters = SignInStartCommandParameters.builder() | ||
.platformComponents(mock<PlatformComponents>()) | ||
.username(emptyString) | ||
|
@@ -485,7 +485,7 @@ class NativeAuthRequestHandlerTest { | |
) | ||
} | ||
|
||
@Test | ||
@Test(expected = ClientException::class) | ||
fun testSignInInitiateWithPasswordCommandParametersWithEmptyUsernameShouldNotThrowException() { | ||
val commandParameters = SignInStartCommandParameters.builder() | ||
.platformComponents(mock<PlatformComponents>()) | ||
|
@@ -644,8 +644,8 @@ class NativeAuthRequestHandlerTest { | |
} | ||
|
||
// sspr start tests | ||
@Test | ||
fun testResetPasswordStartWithEmptyUsernameShouldNotThrowException() { | ||
@Test(expected = ClientException::class) | ||
fun testResetPasswordStartWithEmptyUsernameShouldThrowException() { | ||
val commandParameters = ResetPasswordStartCommandParameters.builder() | ||
.platformComponents(mock<PlatformComponents>()) | ||
.username(emptyString) | ||
|
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 was this removed in the first place?
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 sure about the reason but I would prefer to keep the checking here.