Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Runtime/Procedures/Startup/ProcedureLauncherState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ private async UniTask StartLauncherUIAsync(IFsm<IProcedureManager> procedureOwne
GameApp.Web.RemoveBaseHeader(StartupProcedureUtility.GameFrameXApiKeyHeader);
GameApp.Web.RemoveBaseHeader(StartupProcedureUtility.GameFrameXAppIdHeader);
GameApp.Web.RemoveBaseHeader(StartupProcedureUtility.GameFrameXAppSecretHeader);
GameApp.Web.RemoveBaseHeader(StartupProcedureUtility.GameFrameXTenantSecretHeader);

foreach (var header in StartupProcedureUtility.CreateGameFrameXHeaders(options))
{
Expand Down
6 changes: 4 additions & 2 deletions Runtime/Procedures/StartupProcedureUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ namespace GameFrameX.Startup.Runtime
/// </remarks>
internal static class StartupProcedureUtility
{
public const string GameFrameXApiKeyHeader = "GameFrameX-Api-Key";
public const string GameFrameXApiKeyHeader = "GameFrameX-Tenant-Id";
public const string GameFrameXAppIdHeader = "GameFrameX-App-Id";
public const string GameFrameXAppSecretHeader = "GameFrameX-App-Secret";
public const string GameFrameXTenantSecretHeader = "GameFrameX-Tenant-Secret";

/// <summary>
/// 从流程所有者中获取启动选项。
Expand Down Expand Up @@ -104,7 +105,7 @@ public static Dictionary<string, object> CreateHttpParams(StartupOptions options

public static Dictionary<string, string> CreateGameFrameXHeaders(StartupOptions options)
{
var headers = new Dictionary<string, string>(3);
var headers = new Dictionary<string, string>(4);
if (options == null)
{
return headers;
Expand All @@ -113,6 +114,7 @@ public static Dictionary<string, string> CreateGameFrameXHeaders(StartupOptions
AddHeaderIfNotEmpty(headers, GameFrameXApiKeyHeader, options.GameFrameXApiKey);
AddHeaderIfNotEmpty(headers, GameFrameXAppIdHeader, options.GameFrameXAppId);
AddHeaderIfNotEmpty(headers, GameFrameXAppSecretHeader, options.GameFrameXAppSecret);
AddHeaderIfNotEmpty(headers, GameFrameXTenantSecretHeader, options.GameFrameXTenantSecret);
return headers;
}

Expand Down
3 changes: 2 additions & 1 deletion Runtime/Startup/StartupOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public sealed class StartupOptions : ScriptableObject
[Header("Admin")] [Tooltip("GameFrameX 管理后台的租户ID")]
public string GameFrameXApiKey = "";

[Tooltip("GameFrameX 管理后台的租户密钥")] public string GameFrameXTenantSecret = "";
[Tooltip("GameFrameX 管理后台的应用ID")] public string GameFrameXAppId = "";
[Tooltip("GameFrameX 管理后台的应用密钥")] public string GameFrameXAppSecret = "";

Expand Down Expand Up @@ -48,4 +49,4 @@ public sealed class StartupOptions : ScriptableObject
[Tooltip("启动 UI 的资源路径,传给 IStartupUIHandler。")]
public string LauncherUIResName = "UI/UILauncher";
}
}
}
14 changes: 9 additions & 5 deletions Tests/Runtime/StartupOptionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public void DefaultValues_AreCorrect()
Assert.IsNotNull(options.GlobalInfoUrls);
Assert.AreEqual(0, options.GlobalInfoUrls.Length, "GlobalInfoUrls default should be empty array");
Assert.AreEqual(string.Empty, options.GameFrameXApiKey);
Assert.AreEqual(string.Empty, options.GameFrameXTenantSecret);
Assert.AreEqual(string.Empty, options.GameFrameXAppId);
Assert.AreEqual(string.Empty, options.GameFrameXAppSecret);
Assert.AreEqual(3, options.MaxAttemptsPerUrl);
Expand Down Expand Up @@ -64,28 +65,31 @@ public void HasCreateAssetMenuAttribute()
}

[Test]
public void HasFifteenPublicFields()
public void HasSixteenPublicFields()
{
var publicFields = typeof(StartupOptions).GetFields(BindingFlags.Public | BindingFlags.Instance);
Assert.AreEqual(15, publicFields.Length,
"StartupOptions should expose exactly 15 public fields per spec §3.1.1");
Assert.AreEqual(16, publicFields.Length,
"StartupOptions should expose exactly 16 public fields per spec §3.1.1");
}

[Test]
public void CreateGameFrameXHeaders_OnlyIncludesNonEmptyValues()
{
var options = ScriptableObject.CreateInstance<StartupOptions>();
options.GameFrameXApiKey = "api-key";
options.GameFrameXTenantSecret = "tenant-secret";
options.GameFrameXAppId = "";
options.GameFrameXAppSecret = "app-secret";

var utilityType = typeof(StartupOptions).Assembly.GetType("GameFrameX.Startup.Runtime.StartupProcedureUtility");
var method = utilityType.GetMethod("CreateGameFrameXHeaders", BindingFlags.Public | BindingFlags.Static);
var headers = (Dictionary<string, string>)method.Invoke(null, new object[] { options });

Assert.AreEqual(2, headers.Count);
Assert.AreEqual("api-key", headers["GameFrameX-Api-Key"]);
Assert.AreEqual(3, headers.Count);
Assert.AreEqual("api-key", headers["GameFrameX-Tenant-Id"]);
Assert.AreEqual("tenant-secret", headers["GameFrameX-Tenant-Secret"]);
Assert.AreEqual("app-secret", headers["GameFrameX-App-Secret"]);
Assert.IsFalse(headers.ContainsKey("GameFrameX-Api-Key"));
Assert.IsFalse(headers.ContainsKey("GameFrameX-App-Id"));
}
}
Expand Down