mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 12:33:01 +08:00
Ensure all remaining test usages of IAPIAccess.Login()
also authenticate with second factor
This commit is contained in:
parent
5d26afc531
commit
0d7834af5f
@ -184,7 +184,11 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
CreateTest();
|
CreateTest();
|
||||||
|
|
||||||
AddUntilStep("wait for track to start running", () => Beatmap.Value.Track.IsRunning);
|
AddUntilStep("wait for track to start running", () => Beatmap.Value.Track.IsRunning);
|
||||||
AddStep("log back in", () => API.Login("username", "password"));
|
AddStep("log back in", () =>
|
||||||
|
{
|
||||||
|
API.Login("username", "password");
|
||||||
|
((DummyAPIAccess)API).AuthenticateSecondFactor("abcdefgh");
|
||||||
|
});
|
||||||
|
|
||||||
AddStep("seek to completion", () => Player.GameplayClockContainer.Seek(Player.DrawableRuleset.Objects.Last().GetEndTime()));
|
AddStep("seek to completion", () => Player.GameplayClockContainer.Seek(Player.DrawableRuleset.Objects.Last().GetEndTime()));
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public partial class TestSceneToolbarUserButton : OsuManualInputManagerTestScene
|
public partial class TestSceneToolbarUserButton : OsuManualInputManagerTestScene
|
||||||
{
|
{
|
||||||
|
private DummyAPIAccess dummyAPI => (DummyAPIAccess)API;
|
||||||
|
|
||||||
public TestSceneToolbarUserButton()
|
public TestSceneToolbarUserButton()
|
||||||
{
|
{
|
||||||
Container mainContainer;
|
Container mainContainer;
|
||||||
@ -69,18 +71,20 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestLoginLogout()
|
public void TestLoginLogout()
|
||||||
{
|
{
|
||||||
AddStep("Log out", () => ((DummyAPIAccess)API).Logout());
|
AddStep("Log out", () => dummyAPI.Logout());
|
||||||
AddStep("Log in", () => ((DummyAPIAccess)API).Login("wang", "jang"));
|
AddStep("Log in", () => dummyAPI.Login("wang", "jang"));
|
||||||
|
AddStep("Authenticate via second factor", () => dummyAPI.AuthenticateSecondFactor("abcdefgh"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestStates()
|
public void TestStates()
|
||||||
{
|
{
|
||||||
AddStep("Log in", () => ((DummyAPIAccess)API).Login("wang", "jang"));
|
AddStep("Log in", () => dummyAPI.Login("wang", "jang"));
|
||||||
|
AddStep("Authenticate via second factor", () => dummyAPI.AuthenticateSecondFactor("abcdefgh"));
|
||||||
|
|
||||||
foreach (var state in Enum.GetValues<APIState>())
|
foreach (var state in Enum.GetValues<APIState>())
|
||||||
{
|
{
|
||||||
AddStep($"Change state to {state}", () => ((DummyAPIAccess)API).SetState(state));
|
AddStep($"Change state to {state}", () => dummyAPI.SetState(state));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
Schedule(() =>
|
Schedule(() =>
|
||||||
{
|
{
|
||||||
API.Login("test", "test");
|
API.Login("test", "test");
|
||||||
|
dummyAPI.AuthenticateSecondFactor("abcdefgh");
|
||||||
Child = commentsContainer = new CommentsContainer();
|
Child = commentsContainer = new CommentsContainer();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osu.Game.Overlays.BeatmapSet.Buttons;
|
using osu.Game.Overlays.BeatmapSet.Buttons;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -34,14 +35,22 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
AddStep("set valid beatmap", () => favourite.BeatmapSet.Value = new APIBeatmapSet { OnlineID = 88 });
|
AddStep("set valid beatmap", () => favourite.BeatmapSet.Value = new APIBeatmapSet { OnlineID = 88 });
|
||||||
AddStep("log out", () => API.Logout());
|
AddStep("log out", () => API.Logout());
|
||||||
checkEnabled(false);
|
checkEnabled(false);
|
||||||
AddStep("log in", () => API.Login("test", "test"));
|
AddStep("log in", () =>
|
||||||
|
{
|
||||||
|
API.Login("test", "test");
|
||||||
|
((DummyAPIAccess)API).AuthenticateSecondFactor("abcdefgh");
|
||||||
|
});
|
||||||
checkEnabled(true);
|
checkEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestBeatmapChange()
|
public void TestBeatmapChange()
|
||||||
{
|
{
|
||||||
AddStep("log in", () => API.Login("test", "test"));
|
AddStep("log in", () =>
|
||||||
|
{
|
||||||
|
API.Login("test", "test");
|
||||||
|
((DummyAPIAccess)API).AuthenticateSecondFactor("abcdefgh");
|
||||||
|
});
|
||||||
AddStep("set valid beatmap", () => favourite.BeatmapSet.Value = new APIBeatmapSet { OnlineID = 88 });
|
AddStep("set valid beatmap", () => favourite.BeatmapSet.Value = new APIBeatmapSet { OnlineID = 88 });
|
||||||
checkEnabled(true);
|
checkEnabled(true);
|
||||||
AddStep("set invalid beatmap", () => favourite.BeatmapSet.Value = new APIBeatmapSet());
|
AddStep("set invalid beatmap", () => favourite.BeatmapSet.Value = new APIBeatmapSet());
|
||||||
|
@ -177,7 +177,11 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
AddWaitStep("wait a bit", 5);
|
AddWaitStep("wait a bit", 5);
|
||||||
AddAssert("update not received", () => update == null);
|
AddAssert("update not received", () => update == null);
|
||||||
|
|
||||||
AddStep("log in user", () => dummyAPI.Login("user", "password"));
|
AddStep("log in user", () =>
|
||||||
|
{
|
||||||
|
dummyAPI.Login("user", "password");
|
||||||
|
dummyAPI.AuthenticateSecondFactor("abcdefgh");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -52,7 +52,11 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
AddStep("show user", () => profile.ShowUser(new APIUser { Id = 1 }));
|
AddStep("show user", () => profile.ShowUser(new APIUser { Id = 1 }));
|
||||||
AddToggleStep("toggle visibility", visible => profile.State.Value = visible ? Visibility.Visible : Visibility.Hidden);
|
AddToggleStep("toggle visibility", visible => profile.State.Value = visible ? Visibility.Visible : Visibility.Hidden);
|
||||||
AddStep("log out", () => dummyAPI.Logout());
|
AddStep("log out", () => dummyAPI.Logout());
|
||||||
AddStep("log back in", () => dummyAPI.Login("username", "password"));
|
AddStep("log back in", () =>
|
||||||
|
{
|
||||||
|
dummyAPI.Login("username", "password");
|
||||||
|
dummyAPI.AuthenticateSecondFactor("abcdefgh");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -98,7 +102,11 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
});
|
});
|
||||||
AddStep("logout", () => dummyAPI.Logout());
|
AddStep("logout", () => dummyAPI.Logout());
|
||||||
AddStep("show user", () => profile.ShowUser(new APIUser { Id = 1 }));
|
AddStep("show user", () => profile.ShowUser(new APIUser { Id = 1 }));
|
||||||
AddStep("login", () => dummyAPI.Login("username", "password"));
|
AddStep("login", () =>
|
||||||
|
{
|
||||||
|
dummyAPI.Login("username", "password");
|
||||||
|
dummyAPI.AuthenticateSecondFactor("abcdefgh");
|
||||||
|
});
|
||||||
AddWaitStep("wait some", 3);
|
AddWaitStep("wait some", 3);
|
||||||
AddStep("complete request", () => pendingRequest.TriggerSuccess(TEST_USER));
|
AddStep("complete request", () => pendingRequest.TriggerSuccess(TEST_USER));
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Game.Online.API;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Online
|
namespace osu.Game.Tests.Visual.Online
|
||||||
{
|
{
|
||||||
@ -72,7 +73,11 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
AddAssert("Login overlay is visible", () => login.State.Value == Visibility.Visible);
|
AddAssert("Login overlay is visible", () => login.State.Value == Visibility.Visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logIn() => API.Login("localUser", "password");
|
private void logIn()
|
||||||
|
{
|
||||||
|
API.Login("localUser", "password");
|
||||||
|
((DummyAPIAccess)API).AuthenticateSecondFactor("abcdefgh");
|
||||||
|
}
|
||||||
|
|
||||||
private Comment getUserComment() => new Comment
|
private Comment getUserComment() => new Comment
|
||||||
{
|
{
|
||||||
|
@ -125,7 +125,11 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
assertLoggedOutState();
|
assertLoggedOutState();
|
||||||
|
|
||||||
// moving from logged out -> logged in
|
// moving from logged out -> logged in
|
||||||
AddStep("log back in", () => dummyAPI.Login("username", "password"));
|
AddStep("log back in", () =>
|
||||||
|
{
|
||||||
|
dummyAPI.Login("username", "password");
|
||||||
|
dummyAPI.AuthenticateSecondFactor("abcdefgh");
|
||||||
|
});
|
||||||
assertLoggedInState();
|
assertLoggedInState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user