Skip to content

Commit 2d31fcd

Browse files
author
pgilmorepf
committed
Removing password and username from all the testing, as we've migrated everything to use CustomID.
Summary: Removing password and username from all the testing, as we've migrated everything to use CustomID. Documenting testTitleData.json, and some JCU requirements. fixes T2232 Test Plan: Jenker! Reviewers: zac-playfab, #devtools_in-progress Reviewed By: zac-playfab, #devtools_in-progress Subscribers: zac-playfab Maniphest Tasks: T2232 Differential Revision: https://phab.playfabdev.com/D2492
1 parent 6ceb16c commit 2d31fcd

File tree

14 files changed

+98
-144
lines changed

14 files changed

+98
-144
lines changed

Diff for: JenkinsConsoleUtility/readme.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
JenkinsConsoleUtility Readme
2+
====
3+
4+
We at PlayFab use Jenkins to automate most of our testing, both for our closed-source API-Server, and our open-source SDKs.
5+
6+
JenkinsConsoleUtility (shortened to JCU) is open source, and focuses exclusively on relaying test reports from SDKs built to difficult targets, back into Jenkins in a format familiar to Jenkins. For example, many of our SDKs are deployed to phones or devices, which are not running our Jenkins builder. Jenkins kicks off a build to the device, and then runs JCU, which waits for the device to upload test results. When finished, those test results are posted to the Jenkins job.
7+
8+
There are some requirements to make this work:
9+
* We highly suggest you create a test title which is exclusively for running our tests, which you will not use for your actual game development
10+
* In your own test title, a specific set of CloudScript functions must be appended to your own
11+
* They are provided here: https://github.com/PlayFab/SDKGenerator/blob/master/JenkinsConsoleUtility/jcuCloudScript.js
12+
* You must be running our testing-example projects, provided with most of our sdks
13+
* Any sdk with semi-weekly releases should have this test project included with the SDK
14+
* You must provide a testTitleData.json file to the test-example
15+
* See the detailed described here: https://github.com/PlayFab/SDKGenerator/blob/master/JenkinsConsoleUtility/testTitleData.md
16+
* You must ENABLE the "Allow client to post player statistics" option in the PlayFab Game Manager
17+
* PlayFab Website -> Login -> Find your title -> Settings -> API-Features -> check-box
18+
* For server-authoritative games, or games with leaderboards, this is not suggested, hence the importance of creating a separate title
19+
20+
Full documentation of the JCU will be posted here eventually. This isn't designed to be a primary product for our customers to use. It's open source because there's nothing sensitive here, and we're happy to demonstrate our SDK testing process.

Diff for: JenkinsConsoleUtility/testTitleData.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
testTitleData.json
2+
====
3+
4+
testTitleData.json is a file that is required by all of the example-test projects in most of the PlayFab sdks
5+
6+
Each example project serves two main purposes in each SDK:
7+
* Demonstrate to a developer using PlayFab, how to make successful API calls
8+
* In particular, we demonstrate specific areas of maximum first-time-user benefit, like logging in, Player data and statistics
9+
* We also demonstrate Cloud Script, which is one of our most powerful features, but can also be somewhat difficult to use properly
10+
* We also use this same code internally to determine if the SDK is actually working properly
11+
* This is our internal testing process, made transparent to all of our users, and in fact, usable by their own test-titles
12+
13+
This last portion, "running our tests on your own title" comes with a few requirements
14+
* You must specify a testTitleData.json file which tells our tests which title to use
15+
* You must unlock a security setting that allows clients to set player statistics (This setting should NOT be set for a live game which is server-authoritative)
16+
* NOTE: Some tests have a hard coded titleId="6195" in those tests, which is us being sloppy, and we intend to fix these over time
17+
* Generally, it shouldn't hurt anything if you run your tests on our title, but it's better for both of us if you change this to your title when you see it
18+
19+
The format of the testTitleData.json file is as follows:
20+
```json
21+
{
22+
"titleId": "<Found in PlayFab Game Manager>",
23+
"developerSecretKey": "<Found in PlayFab Game Manager>",
24+
"titleCanUpdateSettings": "true",
25+
"userEmail": "<[email protected]>",
26+
"characterName": "<CharName>"
27+
}
28+
```
29+
30+
Please note characterName is deprecated, and has already been removed from most of the test-examples in our SDKs. For those few that remain, this can be any valid character name (Those test suites will usually create the character).
31+
32+
Please note, the path to testTitleData.json is hard coded in most of the examples to this: "C:/depot/pf-main/tools/SDKBuildScripts/testTitleData.json"
33+
34+
Our own testTitleData.json is located at this location and contains the secret key for title 6195, and thus we do not publish this file. You should change this path to your own testTitleData.json location, wherever it may be.
35+
36+
Philosophy
37+
====
38+
39+
We feel that by showing you our own testing files, as examples of how to use our SDK, we are guaranteeing a few things:
40+
* The example code in those files always works
41+
* Those tests must pass on our own automated testing server in order to be published, and therefore, it is a guaranteed working example of how to make those calls
42+
* Transparency - This is the testing we do for our SDKs
43+
* Note, we have EXTENSIVE testing of the API-server, which is not represented by these tests. These are just the SDK tests
44+
* Promote testing
45+
* Every one of our SDK testing-examples comes with a working test environment, which you can use in your own projects

Diff for: targets/actionscript/source/PlayFabApiTests.as

+3-12
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ package
3333
private static var TITLE_CAN_UPDATE_SETTINGS:Boolean = false;
3434

3535
// Fixed values provided from testInputs
36-
private static var USER_NAME:String;
3736
private static var USER_EMAIL:String;
38-
private static var USER_PASSWORD:String;
39-
private static var CHAR_NAME:String;
4037

4138
// Information fetched by appropriate API calls
4239
private static var playFabId:String;
@@ -90,19 +87,13 @@ package
9087
PlayFabSettings.TitleId = testTitleData.titleId;
9188
PlayFabSettings.DeveloperSecretKey = testTitleData.developerSecretKey;
9289
TITLE_CAN_UPDATE_SETTINGS = testTitleData.titleCanUpdateSettings.toLowerCase() == "true";
93-
USER_NAME = testTitleData.userName;
9490
USER_EMAIL = testTitleData.userEmail;
95-
USER_PASSWORD = testTitleData.userPassword;
96-
CHAR_NAME = testTitleData.characterName;
9791

9892
TITLE_INFO_SET = Boolean(PlayFabSettings.TitleId)
9993
|| Boolean(PlayFabSettings.TitleId)
10094
|| Boolean(PlayFabSettings.DeveloperSecretKey)
10195
|| Boolean(TITLE_CAN_UPDATE_SETTINGS)
102-
|| Boolean(USER_NAME)
103-
|| Boolean(USER_EMAIL)
104-
|| Boolean(USER_PASSWORD)
105-
|| Boolean(CHAR_NAME);
96+
|| Boolean(USER_EMAIL);
10697
return TITLE_INFO_SET;
10798
}
10899

@@ -122,15 +113,15 @@ package
122113

123114
/// <summary>
124115
/// CLIENT API
125-
/// Try to deliberately log in with an inappropriate password,
116+
/// Deliberately log in with an inappropriate password,
126117
/// and verify that the error displays as expected.
127118
/// </summary>
128119
private function InvalidLogin() : void
129120
{
130121
var request:com.playfab.ClientModels.LoginWithEmailAddressRequest = new com.playfab.ClientModels.LoginWithEmailAddressRequest();
131122
request.TitleId = PlayFabSettings.TitleId;
132123
request.Email = USER_EMAIL;
133-
request.Password = USER_PASSWORD + "INVALID";
124+
request.Password = "INVALID";
134125
PlayFabClientAPI.LoginWithEmailAddress(request, Wrap(InvalidLogin_Success, "InvalidLogin_Success"), Wrap(InvalidLogin_Failure, "InvalidLogin_Success"));
135126
}
136127
private function InvalidLogin_Success(result:com.playfab.ClientModels.LoginResult) : void

Diff for: targets/cpp-cocos2dx/ExampleSource/Classes/PlayFabApiTest.h

+3-22
Original file line numberDiff line numberDiff line change
@@ -312,10 +312,7 @@ namespace PlayFabApiTest
312312

313313
// A bunch of constants loaded from testTitleData.json
314314
static const std::string TEST_TITLE_DATA_LOC;
315-
static std::string userName;
316315
static std::string userEmail;
317-
static std::string userPassword;
318-
static std::string characterName;
319316
static bool TITLE_CAN_UPDATE_SETTINGS;
320317
const static std::string TEST_DATA_KEY;
321318
const static std::string TEST_STAT_NAME;
@@ -359,18 +356,12 @@ namespace PlayFabApiTest
359356
// POPULATE THIS SECTION WITH REAL INFORMATION
360357
playFabSettings->titleId = ""; // The titleId for your title, found in the "Settings" section of PlayFab Game Manager
361358
TITLE_CAN_UPDATE_SETTINGS = true; // Make sure this is enabled in your title, found in the "Settings" section, "API Features" section of PlayFab Game Manager
362-
userName = ""; // This is an arbitrary user name, which will be utilized for this test
363359
userEmail = ""; // This is the email for the user
364-
userPassword = ""; // This is the password for the user
365-
characterName = ""; // This should be a valid character on the given user's account
366360
}
367361

368362
// Verify all the inputs won't cause crashes in the tests
369363
return !playFabSettings->titleId.empty()
370-
&& !userName.empty()
371-
&& !userEmail.empty()
372-
&& !userPassword.empty()
373-
&& !characterName.empty();
364+
&& !userEmail.empty();
374365
}
375366

376367
static void PostTestResultsToCloudScript()
@@ -448,15 +439,8 @@ namespace PlayFabApiTest
448439
if (each != end) blah = each->value.GetString();
449440
TITLE_CAN_UPDATE_SETTINGS = (blah.compare("true") == 0 || blah.compare("True") == 0 || blah.compare("TRUE") == 0);
450441

451-
each = testInputs.FindMember("userName");
452-
if (each != end) userName = each->value.GetString();
453442
each = testInputs.FindMember("userEmail");
454443
if (each != end) userEmail = each->value.GetString();
455-
each = testInputs.FindMember("userPassword");
456-
if (each != end) userPassword = each->value.GetString();
457-
458-
each = testInputs.FindMember("characterName");
459-
if (each != end) characterName = each->value.GetString();
460444
}
461445
// Start a test, and block until the threaded response arrives
462446
static void StartTest(PfTestContext& testContext)
@@ -501,7 +485,7 @@ namespace PlayFabApiTest
501485
{
502486
LoginWithEmailAddressRequest request;
503487
request.Email = userEmail;
504-
request.Password = userPassword + "INVALID";
488+
request.Password = "INVALID";
505489
PlayFabClientAPI::LoginWithEmailAddress(request, InvalidLoginSuccess, InvalidLoginFail, &testContext);
506490
}
507491
static void InvalidLoginSuccess(const LoginResult& result, void* customData)
@@ -526,7 +510,7 @@ namespace PlayFabApiTest
526510
static void InvalidRegistration(PfTestContext& testContext)
527511
{
528512
RegisterPlayFabUserRequest request;
529-
request.Username = userName;
513+
request.Username = "x";
530514
request.Email = "x";
531515
request.Password = "x";
532516
PlayFabClientAPI::RegisterPlayFabUser(request, InvalidRegistrationSuccess, InvalidRegistrationFail, &testContext);
@@ -831,10 +815,7 @@ namespace PlayFabApiTest
831815
std::string PlayFabApiTests::_outputSummary;
832816
PlayFabSettings* PlayFabApiTests::playFabSettings;
833817
const std::string PlayFabApiTests::TEST_TITLE_DATA_LOC = "C:/depot/pf-main/tools/SDKBuildScripts/testTitleData.json";
834-
std::string PlayFabApiTests::userName;
835818
std::string PlayFabApiTests::userEmail;
836-
std::string PlayFabApiTests::userPassword;
837-
std::string PlayFabApiTests::characterName;
838819
bool PlayFabApiTests::TITLE_CAN_UPDATE_SETTINGS = false;
839820
const std::string PlayFabApiTests::TEST_DATA_KEY = "testCounter";
840821
const std::string PlayFabApiTests::TEST_STAT_NAME = "str";

Diff for: targets/cpp-windows/UnittestRunner/PlayFabApiTest.cpp

+1-9
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ namespace UnittestRunner
3939
bool TITLE_CAN_UPDATE_SETTINGS = false;
4040

4141
// Fixed values provided from testInputs
42-
string USER_NAME;
4342
string USER_EMAIL;
44-
string USER_PASSWORD;
4543
string CHAR_NAME;
4644

4745
// Information fetched by appropriate API calls
@@ -84,22 +82,16 @@ namespace UnittestRunner
8482
if (each != end) blah = each->value.GetString(); else TITLE_INFO_SET = false;
8583
TITLE_CAN_UPDATE_SETTINGS = (blah.compare("true") == 0 || blah.compare("True") == 0 || blah.compare("TRUE") == 0);
8684

87-
each = testInputs.FindMember("userName");
88-
if (each != end) USER_NAME = each->value.GetString(); else TITLE_INFO_SET = false;
8985
each = testInputs.FindMember("userEmail");
9086
if (each != end) USER_EMAIL = each->value.GetString(); else TITLE_INFO_SET = false;
91-
each = testInputs.FindMember("userPassword");
92-
if (each != end) USER_PASSWORD = each->value.GetString(); else TITLE_INFO_SET = false;
9387

9488
each = testInputs.FindMember("characterName");
9589
if (each != end) CHAR_NAME = each->value.GetString(); else TITLE_INFO_SET = false;
9690

9791
// Verify all the inputs won't cause crashes in the tests
9892
TITLE_INFO_SET &= !PlayFabSettings::titleId.empty()
9993
&& !PlayFabSettings::developerSecretKey.empty()
100-
&& !USER_NAME.empty()
10194
&& !USER_EMAIL.empty()
102-
&& !USER_PASSWORD.empty()
10395
&& !CHAR_NAME.empty();
10496
}
10597

@@ -181,7 +173,7 @@ namespace UnittestRunner
181173
LoginWithEmailAddressRequest request;
182174
request.TitleId = PlayFabSettings::titleId;
183175
request.Email = USER_EMAIL;
184-
request.Password = USER_PASSWORD + "INVALID";
176+
request.Password = "INVALID";
185177

186178
PlayFabClientAPI::LoginWithEmailAddress(request, &LoginCallback, &LoginFailedCallback, nullptr);
187179
ClientApiWait();

Diff for: targets/csharp-flat/UnittestRunner/PlayFabApiTest.cs

+8-35
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using Newtonsoft.Json.Linq;
44
using PlayFab.ClientModels;
5+
using PlayFab.Internal;
56

67
namespace PlayFab.UUnit
78
{
@@ -25,9 +26,7 @@ public class PlayFabApiTest : UUnitTestCase
2526
private static bool TITLE_CAN_UPDATE_SETTINGS = false;
2627

2728
// Fixed values provided from testInputs
28-
private static string USER_NAME;
2929
private static string USER_EMAIL;
30-
private static string USER_PASSWORD;
3130
private static string CHAR_NAME;
3231

3332
// Information fetched by appropriate API calls
@@ -52,18 +51,14 @@ public static void SetTitleInfo(Dictionary<string, string> testInputs)
5251
TITLE_INFO_SET &= testInputs.TryGetValue("titleCanUpdateSettings", out eachValue);
5352
TITLE_INFO_SET &= bool.TryParse(eachValue, out TITLE_CAN_UPDATE_SETTINGS);
5453

55-
TITLE_INFO_SET &= testInputs.TryGetValue("userName", out USER_NAME);
5654
TITLE_INFO_SET &= testInputs.TryGetValue("userEmail", out USER_EMAIL);
57-
TITLE_INFO_SET &= testInputs.TryGetValue("userPassword", out USER_PASSWORD);
5855

5956
TITLE_INFO_SET &= testInputs.TryGetValue("characterName", out CHAR_NAME);
6057

6158
// Verify all the inputs won't cause crashes in the tests
6259
TITLE_INFO_SET &= !string.IsNullOrEmpty(PlayFabDefaultSettings.TitleId)
6360
&& !string.IsNullOrEmpty(PlayFabDefaultSettings.DeveloperSecretKey)
64-
&& !string.IsNullOrEmpty(USER_NAME)
6561
&& !string.IsNullOrEmpty(USER_EMAIL)
66-
&& !string.IsNullOrEmpty(USER_PASSWORD)
6762
&& !string.IsNullOrEmpty(CHAR_NAME);
6863

6964
Client = new PlayFabClientAPI();
@@ -89,7 +84,7 @@ protected override void TearDown()
8984
public void InvalidLogin()
9085
{
9186
// If the setup failed to log in a user, we need to create one.
92-
var task = Client.LoginWithEmailAddressAsync(Client.Settings.TitleId, USER_EMAIL, USER_PASSWORD + "_INVALID");
87+
var task = Client.LoginWithEmailAddressAsync(Client.Settings.TitleId, USER_EMAIL, "INVALID");
9388
try
9489
{
9590
task.Wait();
@@ -109,40 +104,16 @@ public void InvalidLogin()
109104
[UUnitTest]
110105
public void LoginOrRegister()
111106
{
112-
if (!Client.IsClientLoggedIn()) // If we haven't already logged in...
113-
{
114-
var loginTask = Client.LoginWithEmailAddressAsync(Client.Settings.TitleId, USER_EMAIL, USER_PASSWORD);
115-
116-
try
117-
{
118-
loginTask.Wait();
119-
}
120-
catch (Exception ex)
121-
{
122-
UUnitAssert.True(false, ex.Message);
123-
}
124-
UUnitAssert.True(true);
125-
126-
_playFabId = loginTask.Result.PlayFabId; // Needed for subsequent tests
127-
}
128-
129-
if (Client.IsClientLoggedIn())
130-
return; // Success, already logged in
131-
132-
// If the setup failed to log in a user, we need to create one.
133-
var registerTask = Client.RegisterPlayFabUserAsync(Client.Settings.TitleId, USER_NAME, USER_EMAIL, USER_PASSWORD);
107+
var loginTask = Client.LoginWithCustomIDAsync(Client.Settings.TitleId, PlayFabVersion.BuildIdentifier, true);
134108
try
135109
{
136-
registerTask.Wait();
110+
loginTask.Wait();
137111
}
138112
catch (Exception ex)
139113
{
140114
UUnitAssert.True(false, ex.Message);
141115
}
142-
UUnitAssert.True(true);
143-
144-
_playFabId = registerTask.Result.PlayFabId; // Needed for subsequent tests
145-
116+
_playFabId = loginTask.Result.PlayFabId; // Needed for subsequent tests
146117
UUnitAssert.True(Client.IsClientLoggedIn(), "User login failed");
147118
}
148119

@@ -156,7 +127,7 @@ public void LoginWithAdvertisingId()
156127
Client.Settings.AdvertisingIdType = PlayFabDefaultSettings.AD_TYPE_ANDROID_ID;
157128
Client.Settings.AdvertisingIdValue = "PlayFabTestId";
158129

159-
var loginTask = Client.LoginWithEmailAddressAsync(Client.Settings.TitleId, USER_EMAIL, USER_PASSWORD);
130+
var loginTask = Client.LoginWithCustomIDAsync(Client.Settings.TitleId, PlayFabVersion.BuildIdentifier, true);
160131
try
161132
{
162133
loginTask.Wait();
@@ -165,6 +136,8 @@ public void LoginWithAdvertisingId()
165136
{
166137
UUnitAssert.True(false, ex.Message);
167138
}
139+
_playFabId = loginTask.Result.PlayFabId; // Needed for subsequent tests
140+
UUnitAssert.True(Client.IsClientLoggedIn(), "User login failed");
168141
UUnitAssert.StringEquals(PlayFabDefaultSettings.AD_TYPE_ANDROID_ID + "_Successful", Client.Settings.AdvertisingIdType);
169142
}
170143

0 commit comments

Comments
 (0)