Skip to content

Commit

Permalink
Merge branch 'release/1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey committed Jun 16, 2022
2 parents 031070c + c840049 commit 09bdbf6
Show file tree
Hide file tree
Showing 602 changed files with 3,430 additions and 10,300 deletions.
121 changes: 120 additions & 1 deletion Assets/Tests/API/XsollaAuthTests/XsollaAuthUserTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;
using Xsolla.Auth;
using Xsolla.Core;
Expand Down Expand Up @@ -113,7 +114,7 @@ public IEnumerator GetUserInfo_Success()
});
}

//There is a limit for this request, so test only one arguments combination - high risk of request error because of backend rules otherwise
//There is a limit for this request, so test only one arguments combination - high risk of request error because of backend rules
[UnityTest]
public IEnumerator StartAuthByPhoneNumber_Success()
{
Expand Down Expand Up @@ -177,5 +178,123 @@ public IEnumerator OAuthLogout_All_Success()
onError: error => TestHelper.Fail(testName, error));
});
}

[UnityTest]
public IEnumerator ResetPassword_DefaultValues_Success()
{
yield return ResetPassword_TestCore(nameof(ResetPassword_DefaultValues_Success));
}

[UnityTest]
public IEnumerator ResetPassword_de_DE_Locale_Success()
{
yield return ResetPassword_TestCore(nameof(ResetPassword_de_DE_Locale_Success), locale:"de_DE");
}

private IEnumerator ResetPassword_TestCore(string testName, string redirectUri = null, string locale = null)
{

var signInResult = default(TestSignInHelper.SignInResult);
yield return TestSignInHelper.Instance.SignIn(callback: result => signInResult = result);
yield return new WaitWhile(() => signInResult == null);

if (!signInResult.success || Token.Instance == null)
TestHelper.Fail(testName, signInResult);

var userEmail = default(string);
var getInfoError = default(Error);
var busy = true;
XsollaAuth.Instance.GetUserInfo(
token: Token.Instance,
onSuccess: userInfo =>
{
userEmail = userInfo?.email;
busy = false;
},
onError: error =>
{
getInfoError = error;
busy = false;
});

yield return new WaitWhile(() => busy);
if (getInfoError != null)
{
TestHelper.Fail(testName, getInfoError);
yield break;
}
if (userEmail == null)
{
TestHelper.Fail(testName, "UserEmail is NULL");
yield break;
}

XsollaAuth.Instance.ResetPassword(
email: userEmail,
redirectUri: redirectUri,
locale: locale,
onSuccess: () => TestHelper.Pass(testName),
onError: error => TestHelper.Fail(testName, error));
}

[UnityTest]
public IEnumerator ResendConfirmationLink_DefaultValues_Success()
{
yield return ResendConfirmationLink_TestCore(nameof(ResendConfirmationLink_DefaultValues_Success));
}

[UnityTest]
public IEnumerator ResendConfirmationLink_de_DE_Locale_Success()
{
yield return ResendConfirmationLink_TestCore(nameof(ResendConfirmationLink_de_DE_Locale_Success), locale:"de_DE");
}

private IEnumerator ResendConfirmationLink_TestCore(string testName, string redirectUri = null, string state = null, string payload = null, string locale = null)
{

var signInResult = default(TestSignInHelper.SignInResult);
yield return TestSignInHelper.Instance.SignIn(callback: result => signInResult = result);
yield return new WaitWhile(() => signInResult == null);

if (!signInResult.success || Token.Instance == null)
TestHelper.Fail(testName, signInResult);

var userEmail = default(string);
var getInfoError = default(Error);
var busy = true;
XsollaAuth.Instance.GetUserInfo(
token: Token.Instance,
onSuccess: userInfo =>
{
userEmail = userInfo?.email;
busy = false;
},
onError: error =>
{
getInfoError = error;
busy = false;
});

yield return new WaitWhile(() => busy);
if (getInfoError != null)
{
TestHelper.Fail(testName, getInfoError);
yield break;
}
if (userEmail == null)
{
TestHelper.Fail(testName, "UserEmail is NULL");
yield break;
}

XsollaAuth.Instance.ResendConfirmationLink(
username: userEmail,
redirectUri: redirectUri,
state: state,
payload: payload,
locale: locale,
onSuccess: () => TestHelper.Pass(testName),
onError: error => TestHelper.Fail(testName, error));
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 09bdbf6

Please sign in to comment.