routes for serving UI, now tested
This commit is contained in:
parent
7bc6dfbdd3
commit
601755f17a
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
console.log("test app 1 - main");
|
|
@ -0,0 +1,3 @@
|
|||
<html>
|
||||
<body>MAIN - TEST APP 1</body>
|
||||
</html>
|
|
@ -0,0 +1 @@
|
|||
console.log("test app 1 - unauthenticated");
|
|
@ -0,0 +1,3 @@
|
|||
<html>
|
||||
<body>UNAUTHENTICATED - TEST APP 1</body>
|
||||
</html>
|
|
@ -69,10 +69,6 @@ module.exports = (config, app) => {
|
|||
await send(ctx, path, { root: builderPath });
|
||||
}
|
||||
})
|
||||
.get("/:appname", async (ctx) => {
|
||||
ctx.response.status = StatusCodes.OK;
|
||||
ctx.response.body = "UI Served Here";
|
||||
})
|
||||
.post("/:appname/api/authenticate", async (ctx, next) => {
|
||||
const user = await ctx.master.authenticate(
|
||||
ctx.sessionId,
|
||||
|
|
|
@ -2,6 +2,7 @@ const app = require("./testApp")();
|
|||
const authenticateMaster = require("./authenticate");
|
||||
const createNewApp = require("./createNewApp");
|
||||
const multipleInstances = require("./multipleInstances");
|
||||
const serveui = require("./serveui");
|
||||
|
||||
beforeAll(async () => await app.start())
|
||||
|
||||
|
@ -11,5 +12,6 @@ describe("authenticateMaster", () => authenticateMaster(app, "_master", "masterO
|
|||
describe("createNewApp", () => createNewApp(app));
|
||||
describe("authenticateTestApp", () => authenticateMaster(app, "testApp", "testAppUser1"));
|
||||
describe("multipleInstances", () => multipleInstances(app));
|
||||
describe("serveUi", () => serveui(app));
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
const statusCodes = require("../utilities/statusCodes");
|
||||
const { readFile } = require("../utilities/fsawait");
|
||||
|
||||
module.exports = (app) => {
|
||||
|
||||
it("should serve unauthenticated index.html as default", async () => {
|
||||
const response = await app.get("/testApp")
|
||||
.expect(statusCodes.OK);
|
||||
|
||||
const expectedIndexHtml = await readFile("appPackages/testApp/ui/unauthenticated/public/index.html", "utf8");
|
||||
|
||||
expect(response.text).toBe(expectedIndexHtml);
|
||||
|
||||
});
|
||||
|
||||
it("should serve specified files when unauthenticated", async () => {
|
||||
const response = await app.get("/testApp/app.js")
|
||||
.expect(statusCodes.OK);
|
||||
|
||||
const expectedFile = await readFile("appPackages/testApp/ui/unauthenticated/public/app.js", "utf8");
|
||||
|
||||
expect(response.text).toBe(expectedFile);
|
||||
|
||||
});
|
||||
|
||||
it("should serve main index.html as default when authenticated", async () => {
|
||||
const response = await app.get("/testApp")
|
||||
.set("cookie", app.credentials.testAppUser1.cookie)
|
||||
.expect(statusCodes.OK);
|
||||
|
||||
const expectedIndexHtml = await readFile("appPackages/testApp/ui/main/public/index.html", "utf8");
|
||||
|
||||
expect(response.text).toBe(expectedIndexHtml);
|
||||
|
||||
});
|
||||
|
||||
it("should serve specified files when authenticated", async () => {
|
||||
const response = await app.get("/testApp/app.js")
|
||||
.set("cookie", app.credentials.testAppUser1.cookie)
|
||||
.expect(statusCodes.OK);
|
||||
|
||||
const expectedFile = await readFile("appPackages/testApp/ui/main/public/app.js", "utf8");
|
||||
|
||||
expect(response.text).toBe(expectedFile);
|
||||
|
||||
});
|
||||
|
||||
}
|
|
@ -64,10 +64,10 @@ const applictionVersionPath = (appname, versionId) =>
|
|||
join("..", getRuntimePackageDirectory(appname, versionId))
|
||||
|
||||
const publicPaths = (appPath) => ({
|
||||
mainUiPath: join(
|
||||
appPath, "ui", "main", "public"),
|
||||
unauthenticatedUiPath: join(
|
||||
appPath, "ui", "unauthenticated", "public")
|
||||
mainUiPath: resolve(join(
|
||||
__dirname, appPath, "ui", "main", "public")),
|
||||
unauthenticatedUiPath: resolve(join(
|
||||
__dirname, appPath, "ui", "unauthenticated", "public"))
|
||||
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue