public void WhenLoadPathUsesHttp_AndInsecureHttpAllowed_BuildSucceeds() { #if UNITY_2022_1_OR_NEWER InsecureHttpOption oldHttpOption = PlayerSettings.insecureHttpOption; PlayerSettings.insecureHttpOption = InsecureHttpOption.AlwaysAllowed; string remoteLoadPathId = Settings.profileSettings.GetProfileDataByName(AddressableAssetSettings.kRemoteLoadPath).Id; string oldRemoteLoadPath = Settings.profileSettings.GetValueById(Settings.activeProfileId, remoteLoadPathId); Settings.profileSettings.SetValue(Settings.activeProfileId, AddressableAssetSettings.kRemoteLoadPath, "http://insecureconnection/"); AddressableAssetGroup assetGroup = Settings.CreateGroup("InsecureConnections", false, false, false, null, typeof(BundledAssetGroupSchema)); assetGroup.GetSchema <BundledAssetGroupSchema>().BuildPath.SetVariableById(Settings, Settings.profileSettings.GetProfileDataByName(AddressableAssetSettings.kRemoteBuildPath).Id); assetGroup.GetSchema <BundledAssetGroupSchema>().LoadPath.SetVariableById(Settings, Settings.profileSettings.GetProfileDataByName(AddressableAssetSettings.kRemoteLoadPath).Id); string assetPath = Path.Combine(TestFolder, "insecureConnectionsTest.prefab"); PrefabUtility.SaveAsPrefabAsset(new GameObject(), assetPath); Settings.CreateOrMoveEntry(AssetDatabase.AssetPathToGUID(assetPath), assetGroup, false, false); var context = new AddressablesDataBuilderInput(Settings); BuildScriptBase db = (BuildScriptBase)Settings.DataBuilders.Find(x => x.GetType() == typeof(BuildScriptPackedMode)); db.BuildData <AddressablesPlayerBuildResult>(context); LogAssert.NoUnexpectedReceived(); Settings.RemoveGroup(assetGroup); Settings.profileSettings.SetValue(Settings.activeProfileId, AddressableAssetSettings.kRemoteLoadPath, oldRemoteLoadPath); AssetDatabase.DeleteAsset(assetPath); PlayerSettings.insecureHttpOption = oldHttpOption; #else Assert.Ignore($"Skipping test {nameof(WhenLoadPathUsesHttp_AndInsecureHttpAllowed_BuildSucceeds)}."); #endif }
public void WhenLoadPathUsesHttp_AndInsecureHttpNotAllowed_BuildLogsWarning() { #if UNITY_2022_1_OR_NEWER InsecureHttpOption oldHttpOption = PlayerSettings.insecureHttpOption; PlayerSettings.insecureHttpOption = InsecureHttpOption.NotAllowed; string remoteLoadPathId = Settings.profileSettings.GetProfileDataByName(AddressableAssetSettings.kRemoteLoadPath).Id; string oldRemoteLoadPath = Settings.profileSettings.GetValueById(Settings.activeProfileId, remoteLoadPathId); Settings.profileSettings.SetValue(Settings.activeProfileId, AddressableAssetSettings.kRemoteLoadPath, "http://insecureconnection/"); AddressableAssetGroup assetGroup = Settings.CreateGroup("InsecureConnections", false, false, false, null, typeof(BundledAssetGroupSchema)); assetGroup.GetSchema <BundledAssetGroupSchema>().BuildPath.SetVariableById(Settings, Settings.profileSettings.GetProfileDataByName(AddressableAssetSettings.kRemoteBuildPath).Id); assetGroup.GetSchema <BundledAssetGroupSchema>().LoadPath.SetVariableById(Settings, Settings.profileSettings.GetProfileDataByName(AddressableAssetSettings.kRemoteLoadPath).Id); string assetPath = Path.Combine(TestFolder, "insecureConnectionsTest.prefab"); PrefabUtility.SaveAsPrefabAsset(new GameObject(), assetPath); Settings.CreateOrMoveEntry(AssetDatabase.AssetPathToGUID(assetPath), assetGroup, false, false); var context = new AddressablesDataBuilderInput(Settings); BuildScriptBase db = (BuildScriptBase)Settings.DataBuilders.Find(x => x.GetType() == typeof(BuildScriptPackedMode)); db.BuildData <AddressablesPlayerBuildResult>(context); LogAssert.Expect(LogType.Warning, $"Addressable group {assetGroup.Name} uses insecure http for its load path. To allow http connections for UnityWebRequests, change your settings in Edit > Project Settings > Player > Other Settings > Configuration > Allow downloads over HTTP."); Settings.RemoveGroup(assetGroup); Settings.profileSettings.SetValue(Settings.activeProfileId, AddressableAssetSettings.kRemoteLoadPath, oldRemoteLoadPath); AssetDatabase.DeleteAsset(assetPath); PlayerSettings.insecureHttpOption = oldHttpOption; #else Assert.Ignore($"Skipping test {nameof(WhenLoadPathUsesHttp_AndInsecureHttpNotAllowed_BuildLogsWarning)}."); #endif }
public void WhenBundleLocalCatalogEnabled_BuildScriptPacked_DoesNotCreatePerformanceLogReport() { string logPath = $"Library/com.unity.addressables/aa/{PlatformMappingService.GetPlatformPathSubFolder()}/buildlogtep.json"; if (File.Exists(logPath)) { File.Delete(logPath); } Settings.BundleLocalCatalog = true; var context = new AddressablesDataBuilderInput(Settings); BuildScriptBase db = (BuildScriptBase)Settings.DataBuilders.Find(x => x.GetType() == typeof(BuildScriptPackedMode)); Assert.IsFalse(File.Exists(logPath)); // make sure file does not exist before build var res = db.BuildData <AddressablesPlayerBuildResult>(context); Assert.IsFalse(File.Exists(logPath)); }