test: change secrets.cs to read from env

This commit is contained in:
alexiscatnip
2022-08-06 02:43:06 +08:00
committed by alexiscatnip
parent 68ce9a7fa6
commit 3a7d379231
4 changed files with 45 additions and 43 deletions
+2 -2
View File
@@ -27,8 +27,8 @@ namespace Raindrop.Tests.LMV_ExtendedTests
* UnityEngine.TestTools.LogAssert.Expect */
instance.Client.Settings.SEND_AGENT_APPEARANCE = false;
var fullUsername = Secrets.GridUsers[userIdx];
var password = Secrets.GridPass[userIdx];
var fullUsername = Secrets.GetUsername();
var password = Secrets.GetPassword();
Assert.IsFalse(string.IsNullOrWhiteSpace(fullUsername),
"LMVTestAgentUsername is empty. " +
"Live NetworkTests cannot be performed.");
+2 -2
View File
@@ -60,8 +60,8 @@ namespace OpenMetaverse.Tests
[OneTimeSetUp]
public void Init()
{
var fullusername = Secrets.GridUsers[0];
var password = Secrets.GridPass[0];
var fullusername = Secrets.GetUsername();
var password = Secrets.GetPassword();
Assert.IsFalse(string.IsNullOrWhiteSpace(fullusername), "LMVTestAgentUsername is empty. Live NetworkTests cannot be performed.");
Assert.IsFalse(string.IsNullOrWhiteSpace(password), "LMVTestAgentPassword is empty. Live NetworkTests cannot be performed.");
var username = fullusername.Split(' ');
@@ -68,17 +68,14 @@ namespace Raindrop.Tests.RaindropFullIntegrationTests
var uiSrv = ServiceLocator.Instance.Get<UIService>();
//Finally, perform 2x login-logout for each test-user!
for (int loginCredIdx = 0; loginCredIdx < Secrets.GridUsers.Count; loginCredIdx++)
{
int times = 2;
yield return Login.DoExhaustiveLogins(
Secrets.GridUsers[loginCredIdx],
Secrets.GridPass[loginCredIdx],
Secrets._gridFriendlyNames[loginCredIdx],
times,
instance, uiSrv);
}
// Login,logout 2 times for the test-user
int times = 2;
yield return Login.DoExhaustiveLogins(
Secrets.GetUsername(),
Secrets.GetPassword(),
Secrets.GetGridFriendlyName(),
times,
instance, uiSrv);
yield break;
}
@@ -87,9 +84,9 @@ namespace Raindrop.Tests.RaindropFullIntegrationTests
[Timeout(100000000)]
public IEnumerator LoginAndDoNothing()
{
int userIdx = 2;
Debug.Log("Logging to " + Secrets._gridFriendlyNames[userIdx]);
string friendlyName_grid = Secrets.GetGridFriendlyName();
Debug.Log("Logging to " + friendlyName_grid);
GetTo_LoginScreen();
@@ -107,7 +104,6 @@ namespace Raindrop.Tests.RaindropFullIntegrationTests
// 1c. do "select grid by ui"
//get knwon grids
var grids = instance.GridManger.Grids;
string friendlyName_grid = Secrets._gridFriendlyNames[userIdx];
yield return LoginTests.Utils.UIHelpers.Click_Dropdown_Then_Select_ByString(
"GridDropdown",
friendlyName_grid
@@ -119,7 +115,9 @@ namespace Raindrop.Tests.RaindropFullIntegrationTests
//1b. we are on the login screen. do login. assert logged in.
Assert.IsTrue(uiSrv.GetPresentCanvasType() == CanvasType.Login);
yield return Login.StartLogin(Secrets.GridUsers[userIdx], Secrets.GridPass[userIdx]);
yield return Login.StartLogin(
Secrets.GetUsername(),
Secrets.GetPassword());
// Assert.True(uiSrv._loadingController.IsVisible, "expected: loading screen is visible.");
yield return new WaitForSeconds(12);
+27 -23
View File
@@ -1,34 +1,38 @@
using System.Collections.Generic;
using System;
using UnityEngine.Assertions;
namespace Tests
{
//store the passwords used in integration test.
public static class Secrets
{
// the names of the grid service, defined in the friendlyname attribute in the grids.xml file.
public static List<string> _gridFriendlyNames = new List<string>()
public static string GetUsername()
{
"Second Life (agni)",
"Metropolis Metaversum",
"Local Host"
// "https://login.agni.lindenlab.com/cgi-bin/login.cgi",
// "login.metro.land"
};
// user name
public static List<string> GridUsers = new List<string>()
string res =
Environment.GetEnvironmentVariable("USERNAME_SECONDLIFE");
Assert.IsTrue(
res != null,
"Env: USERNAME_SECONDLIFE undefined.");
return res;
}
public static string GetPassword()
{
"***REMOVED*** Resident",
"Raindrop Raindrop",
"Test User"
};
// password
public static List<string> GridPass = new List<string>()
string res =
Environment.GetEnvironmentVariable("PASSWORD_SECONDLIFE");
Assert.IsTrue(
res != null,
"Env: PASSWORD_SECONDLIFE undefined.");
return res;
}
public static string GetGridFriendlyName()
{
"I am a little ",
"silly to put the password ",
"into source control "
};
string res =
Environment.GetEnvironmentVariable("GRIDFRIENDLYNAME_SECONDLIFE");
Assert.IsTrue(
res != null,
"Env: GRIDFRIENDLYNAME_SECONDLIFE undefined.");
return res;
}
}
}