1
0
Fork 0

Fixed installing of Apps containing an internal app folder

This commit is contained in:
Michael Hackstein 2015-03-16 10:27:32 +01:00
parent ce7b75064a
commit 4543668a07
2 changed files with 27 additions and 6 deletions

View File

@ -102,14 +102,13 @@ describe("Foxx Manager install", function() {
}
});
/*
it("with malformed name", function() {
try {
FoxxManager.install(fs.join(basePath, "malformed-name"), "/unittest/broken");
expect(true).toBeFalsy("Managed to install broken application");
} catch(e) {
expect(e instanceof ArangoError).toBeTruthy();
expect(e.errorNum).toEqual(errors.ERROR_MANIFEST_FILE_ATTRIBUTE_MISSING.code);
expect(e.errorNum).toEqual(errors.ERROR_INVALID_APPLICATION_MANIFEST.code);
}
});
@ -119,10 +118,9 @@ describe("Foxx Manager install", function() {
expect(true).toBeFalsy("Managed to install broken application");
} catch(e) {
expect(e instanceof ArangoError).toBeTruthy();
expect(e.errorNum).toEqual(errors.ERROR_MANIFEST_FILE_ATTRIBUTE_MISSING.code);
expect(e.errorNum).toEqual(errors.ERROR_INVALID_APPLICATION_MANIFEST.code);
}
});
*/
it("with malformed controller file", function() {
try {
@ -243,6 +241,7 @@ describe("Foxx Manager install", function() {
});
describe("success with", function() {
it("a minimal app", function() {
try {
FoxxManager.install(fs.join(basePath, "minimal-working-manifest"), "/unittest/broken");
@ -251,6 +250,16 @@ describe("Foxx Manager install", function() {
}
FoxxManager.uninstall("/unittest/broken");
});
it("an app containing a sub-folder 'app'", function() {
try {
FoxxManager.install(fs.join(basePath, "interior-app-path"), "/unittest/broken");
} catch(e) {
expect(true).toBeFalsy("Could not install an app with sub-folder 'app'.");
}
FoxxManager.uninstall("/unittest/broken");
});
});
describe("should not install on invalid mountpoint", function() {

View File

@ -83,7 +83,7 @@
////////////////////////////////////////////////////////////////////////////////
var filterAppRoots = function(folder) {
return /APP$/i.test(folder);
return /[\\\/]APP$/i.test(folder) && !/(APP[\\\/])(.*)APP$/i.test(folder);
};
////////////////////////////////////////////////////////////////////////////////
@ -292,7 +292,6 @@
mf = JSON.parse(fs.read(file));
} catch (err) {
msg = "Cannot parse app manifest '" + file + "': " + String(err);
console.errorLines(msg);
throw new ArangoError({
errorNum: errors.ERROR_INVALID_APPLICATION_MANIFEST.code,
errorMessage: errors.ERROR_INVALID_APPLICATION_MANIFEST.message
@ -300,6 +299,19 @@
}
try {
checkManifest(file, mf);
if (!/^[a-zA-Z\-_][a-zA-Z0-9\-_]*$/.test(mf.name)) {
throw new ArangoError({
errorNum: errors.ERROR_INVALID_APPLICATION_MANIFEST.code,
errorMessage: "The App name can only contain a to z, A to Z, 0-9, '-' and '_'."
});
}
if (!/^\d+\.\d+(\.\d+)?$$/.test(mf.version)) {
throw new ArangoError({
errorNum: errors.ERROR_INVALID_APPLICATION_MANIFEST.code,
errorMessage: "The version requires the format: <major>.<minor>.<bugfix>, all have to be integer numbers."
});
}
} catch (err) {
console.error("Manifest file '%s' is invald: %s", file, err.errorMessage);
if (err.hasOwnProperty("stack")) {