Add unit test for AndroidInsecureFileModeEnabled config (#932)

* Add unit test for AndroidInsecureFileModeEnabled config

* Update
This commit is contained in:
Ezio Li 2023-11-27 13:57:41 +08:00 коммит произвёл GitHub
Родитель a00eb70230
Коммит 764858246d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 52 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,29 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.
import * as assert from "assert";
import * as fs from "fs";
import * as path from "path";
import { ConfigurationHelper } from "../../src/common/configurationHelper";
suite("configurationHelper", function () {
test("should get AndroidInsecureFileMode value correctly", (done: Mocha.Done) => {
const disableXmlContentPath = path.resolve(
__dirname,
"../resources/testAndroidFileModeProject/disableFileModeConfig.xml",
);
const disableXmlContent = fs.readFileSync(disableXmlContentPath, "utf-8");
const disableStatus =
ConfigurationHelper.getAndroidInsecureFileModeStatus(disableXmlContent);
assert.strictEqual(disableStatus, true);
const enableXmlContentPath = path.resolve(
__dirname,
"../resources/testAndroidFileModeProject/enableFileModeConfig.xml",
);
const enableXmlContent = fs.readFileSync(enableXmlContentPath, "utf-8");
const enableStatus = ConfigurationHelper.getAndroidInsecureFileModeStatus(enableXmlContent);
assert.strictEqual(enableStatus, false);
done();
});
});

Просмотреть файл

@ -0,0 +1,11 @@
<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.hellocordova" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>HelloCordova</name>
<description>Sample Apache Cordova App</description>
<author email="dev@cordova.apache.org" href="https://cordova.apache.org">
Apache Cordova Team
</author>
<content src="index.html" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
</widget>

Просмотреть файл

@ -0,0 +1,12 @@
<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.hellocordova" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>HelloCordova</name>
<description>Sample Apache Cordova App</description>
<author email="dev@cordova.apache.org" href="https://cordova.apache.org">
Apache Cordova Team
</author>
<content src="index.html" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<preference name="AndroidInsecureFileModeEnabled" value="true" />
</widget>