diff --git a/.gitea/workflows/action_push.yml b/.gitea/workflows/action_push.yml new file mode 100644 index 0000000..7e2406a --- /dev/null +++ b/.gitea/workflows/action_push.yml @@ -0,0 +1,11 @@ +name: Push Action + +on: + push: + branches: + - '!**' + +jobs: + test: + uses: ./.gitea/workflows/test.yml + diff --git a/.gitea/workflows/action_tag.yml b/.gitea/workflows/action_tag.yml new file mode 100644 index 0000000..6efed72 --- /dev/null +++ b/.gitea/workflows/action_tag.yml @@ -0,0 +1,16 @@ +name: Tag Action + +on: + push: + tags: + - v* + +jobs: + test: + uses: ./.gitea/workflows/test.yml + release_code: + needs: test + uses: ./.gitea/workflows/release_code.yml + release_amd: + needs: [test, release_code] + uses: ./.gitea/workflows/release_amd.yml \ No newline at end of file diff --git a/.gitea/workflows/release_amd.yml b/.gitea/workflows/release_amd.yml new file mode 100644 index 0000000..59a1dc7 --- /dev/null +++ b/.gitea/workflows/release_amd.yml @@ -0,0 +1,39 @@ +name: Outbag AMD Release + +on: + workflow_call: + inputs: + secrets: + + +jobs: + release-amd: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Install Dependencies + run: npm ci + + - name: Build + run: | + mkdir build + npm run bundleRelease + + - name: Build AMD + run: | + npm run build-amd + mkdir upload + cp build/bin/* upload + - name: setup go + uses: https://github.com/actions/setup-go@v4 + with: + go-version: '>=1.20.1' + - name: Create Release AMD + id: gitea-release-amd + uses: https://gitea.com/actions/release-action@main + with: + files: | + upload/** + api_key: '${{ secrets.RELEASE_TOKEN }}' diff --git a/.gitea/workflows/release_code.yml b/.gitea/workflows/release_code.yml new file mode 100644 index 0000000..72ab629 --- /dev/null +++ b/.gitea/workflows/release_code.yml @@ -0,0 +1,46 @@ +name: Outbag Code release + +on: + workflow_call: + inputs: + secrets: + +jobs: + release-code: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Install Dependencies + run: npm ci + + - name: Build + run: | + mkdir build + npm run prepublish + + - name: Build Code + run: | + apt-get update + apt-get install zip tar -y + mkdir outbag_server + mkdir outbag_server/dist + mkdir upload + cp -r dist/* outbag_server/dist + cp package.json outbag_server + cp package-lock.json outbag_server + cp readme.md outbag_server + zip -r upload/OutbagServer.zip outbag_server/* + tar -czvf upload/OutbagServer.tar.gz outbag_server/* + - name: setup go + uses: https://github.com/actions/setup-go@v4 + with: + go-version: '>=1.20.1' + - name: Create Release Code + id: gitea-release-code + uses: https://gitea.com/actions/release-action@main + with: + files: | + upload/** + api_key: '${{ secrets.RELEASE_TOKEN }}' diff --git a/.gitea/workflows/test.yaml b/.gitea/workflows/test.yml similarity index 94% rename from .gitea/workflows/test.yaml rename to .gitea/workflows/test.yml index 7a6c119..76b44ac 100644 --- a/.gitea/workflows/test.yaml +++ b/.gitea/workflows/test.yml @@ -1,6 +1,9 @@ name: Outbag Tests -on: [push] +on: + workflow_call: + inputs: + secrets: jobs: test: diff --git a/test.juml b/test.juml index c782c8b..7070e5f 100644 --- a/test.juml +++ b/test.juml @@ -4,7 +4,7 @@ PORT=7224 PORTexposed=7224 PATHexposed=/ -URL=localhost +URL=127.0.0.1 CertLiveSec=2592000 [ssl] diff --git a/tests/tests/post.js b/tests/tests/post.js index 59273bd..37ca1d1 100644 --- a/tests/tests/post.js +++ b/tests/tests/post.js @@ -18,29 +18,29 @@ const list = [ ["signup", async (req) => { await req({}, "signup", { name: name1, - server: "localhost:7224", + server: "127.0.0.1:7224", accountKey }, "ok", ""); await req({}, "signup", { name: name1, - server: "localhost:7224", + server: "127.0.0.1:7224", accountKey }, "error", act_error.ACCOUNT_EXISTS); await req({}, "signup", { name: name2, - server: "localhost:7224", + server: "127.0.0.1:7224", accountKey }, "ok", ""); await req({}, "signup", { name: name2, - server: "localhost:7224", + server: "127.0.0.1:7224", accountKey }, "error", act_error.config); }], ["remote", async (req) => { - let signature = (await req({ "authorization": `Digest name=${name1} server=localhost:7224 accountKey=${accountKey}` }, + let signature = (await req({ "authorization": `Digest name=${name1} server=127.0.0.1:7224 accountKey=${accountKey}` }, "createSignature", { publicKey }, "ok", null)).sign; @@ -51,7 +51,7 @@ const list = [ "authorization": `Bearer ${token}` }, "remote1", { name: name1, - server: "localhost:7223", + server: "127.0.0.1:7223", publicKey, sign: signature }, "error", act_error.SIGNATURE); @@ -60,7 +60,7 @@ const list = [ "authorization": `Bearer ${token}` }, "remote1", { name: name1, - server: "localhost:7224", + server: "127.0.0.1:7224", publicKey, sign: falseSignature }, "error", act_error.SIGNATURE); @@ -69,7 +69,7 @@ const list = [ "authorization": `Bearer ${token}` }, "remote1", { name: name1, - server: "localhost:7224", + server: "127.0.0.1:7224", publicKey, sign: signature }, "ok", null)).challenge; @@ -78,7 +78,7 @@ const list = [ "authorization": `Bearer ${token}` }, "remote1", { name: name1, - server: "localhost:7224", + server: "127.0.0.1:7224", publicKey, sign: signature }, "error", act_error.WRONG_STATE); @@ -97,7 +97,7 @@ const list = [ }], ["account", async (req) => { await req({ - "authorization": `Digest name=${name1} server=localhost:7224 accountKey=${accountKey}` + "authorization": `Digest name=${name1} server=127.0.0.1:7224 accountKey=${accountKey}` }, "getMyAccount", {}, "ok", { rights: PERMISSIONS.ALL, name: name1, @@ -107,7 +107,7 @@ const list = [ maxUsersPerRoom: 2, }); await req({ - "authorization": `Digest name=${name2} server=localhost:7224 accountKey=${accountKey}` + "authorization": `Digest name=${name2} server=127.0.0.1:7224 accountKey=${accountKey}` }, "getMyAccount", {}, "ok", { rights: PERMISSIONS.DEFAULT, name: name2, @@ -118,31 +118,31 @@ const list = [ }); }], ["change account", async (req) => { await req({ - "authorization": `Digest name=${name2} server=localhost:7224 accountKey=${accountKey}` + "authorization": `Digest name=${name2} server=127.0.0.1:7224 accountKey=${accountKey}` }, "changePassword", { accountKey: accountKey + "lol" }, "ok", ""); await req({}, "signin", { name: name2, - server: "localhost:7224", + server: "127.0.0.1:7224", accountKey }, "error", act_error.AUTH); await req({}, "signin", { name: name2, - server: "localhost:7224", + server: "127.0.0.1:7224", accountKey: accountKey + "lol" }, "ok", ""); await req({ - "authorization": `Digest name=${name2} server=localhost:7224 accountKey=${accountKey + "lol"}` + "authorization": `Digest name=${name2} server=127.0.0.1:7224 accountKey=${accountKey + "lol"}` }, "deleteAccount", {}, "ok", ""); await req({}, "signin", { name: name2, - server: "localhost:7224", + server: "127.0.0.1:7224", accountKey: accountKey + "lol" }, "error", act_error.AUTH); }], ["admin", async (req) => { let resp = await req({ - "authorization": `Digest name=${name1} server=localhost:7224 accountKey=${accountKey}` + "authorization": `Digest name=${name1} server=127.0.0.1:7224 accountKey=${accountKey}` }, "getAccounts", {}, "ok", [ { accID: 1, @@ -167,13 +167,13 @@ const list = [ } ]); await req({ - "authorization": `Digest name=${name1} server=localhost:7224 accountKey=${accountKey}` + "authorization": `Digest name=${name1} server=127.0.0.1:7224 accountKey=${accountKey}` }, "setPermissions", { accID: resp[1].accID, rights: 5 }, "ok", ""); await req({ - "authorization": `Digest name=${name1} server=localhost:7224 accountKey=${accountKey}` + "authorization": `Digest name=${name1} server=127.0.0.1:7224 accountKey=${accountKey}` }, "getAccounts", {}, "ok", [ { accID: 1, @@ -198,14 +198,14 @@ const list = [ } ]); await req({ - "authorization": `Digest name=${name1} server=localhost:7224 accountKey=${accountKey}` + "authorization": `Digest name=${name1} server=127.0.0.1:7224 accountKey=${accountKey}` }, "addOTA", { token: "12345678", expires: uts() + 1, usesLeft: -1 }, "ok", ""); await req({ - "authorization": `Digest name=${name1} server=localhost:7224 accountKey=${accountKey}` + "authorization": `Digest name=${name1} server=127.0.0.1:7224 accountKey=${accountKey}` }, "getOTAs", {}, "ok", [ { token: "12345678", @@ -214,7 +214,7 @@ const list = [ } ]); await req({ - "authorization": `Digest name=${name1} server=localhost:7224 accountKey=${accountKey}` + "authorization": `Digest name=${name1} server=127.0.0.1:7224 accountKey=${accountKey}` }, "addOTA", { token: "abc", expires: -1, @@ -222,34 +222,34 @@ const list = [ }, "ok", ""); await wait(2000); await req({ - "authorization": `Digest name=${name1} server=localhost:7224 accountKey=${accountKey}` + "authorization": `Digest name=${name1} server=127.0.0.1:7224 accountKey=${accountKey}` }, "getOTAs", {}, "ok", [{ token: "abc", expires: -1, usesLeft: -1 }]); await req({ - "authorization": `Digest name=${name1} server=localhost:7224 accountKey=${accountKey}` + "authorization": `Digest name=${name1} server=127.0.0.1:7224 accountKey=${accountKey}` }, "deleteOTA", { token: "abc" }, "ok", ""); await req({ - "authorization": `Digest name=${name1} server=localhost:7224 accountKey=${accountKey}` + "authorization": `Digest name=${name1} server=127.0.0.1:7224 accountKey=${accountKey}` }, "getOTAs", {}, "ok", []); }], ["room Owner", async (req) => { await req({ - "authorization": `Digest name=${name1} server=localhost:7224 accountKey=${accountKey}` + "authorization": `Digest name=${name1} server=127.0.0.1:7224 accountKey=${accountKey}` }, "createRoom", { room: room1, - server: "localhost:7224", + server: "127.0.0.1:7224", title: "Test Room 1", description: "some desc", visibility: 0, icon: "shopping" }, "ok", ""); await req({ - "authorization": `Digest name=${name1} server=localhost:7224 accountKey=${accountKey}` + "authorization": `Digest name=${name1} server=127.0.0.1:7224 accountKey=${accountKey}` }, "createRoom", { room: room1, - server: "localhost:7224", + server: "127.0.0.1:7224", title: "Test Room 1", description: "some desc", visibility: 0, @@ -257,20 +257,20 @@ const list = [ }, "error", act_error.ROOM_EXISTS); await req({ - "authorization": `Digest name=${name1} server=localhost:7224 accountKey=${accountKey}` + "authorization": `Digest name=${name1} server=127.0.0.1:7224 accountKey=${accountKey}` }, "createRoom", { room: room2, - server: "localhost:7224", + server: "127.0.0.1:7224", title: "Test Room 2", description: "some desc 2", visibility: 1, icon: "" }, "ok", ""); await req({ - "authorization": `Digest name=${name1} server=localhost:7224 accountKey=${accountKey}` + "authorization": `Digest name=${name1} server=127.0.0.1:7224 accountKey=${accountKey}` }, "createRoom", { room: room3, - server: "localhost:7224", + server: "127.0.0.1:7224", title: "Test Room 2", description: "some desc 2", visibility: 1, @@ -278,11 +278,11 @@ const list = [ }, "error", act_error.ROOM_LIMIT); await req({ - "authorization": `Digest name=${name1} server=localhost:7224 accountKey=${accountKey}` + "authorization": `Digest name=${name1} server=127.0.0.1:7224 accountKey=${accountKey}` }, "listRooms", {}, "ok", [ { name: room1, - server: "localhost:7224", + server: "127.0.0.1:7224", owner: name1, rights: 0b11111, title: "Test Room 1", @@ -293,7 +293,7 @@ const list = [ confirmed: true }, { name: room2, - server: "localhost:7224", + server: "127.0.0.1:7224", owner: name1, rights: 0b11111, title: "Test Room 2", @@ -305,32 +305,32 @@ const list = [ } ]); await req({ - "authorization": `Digest name=${name1} server=localhost:7224 accountKey=${accountKey}` + "authorization": `Digest name=${name1} server=127.0.0.1:7224 accountKey=${accountKey}` }, "deleteRoom", { room: room2 + "lol", - server: "localhost:7224" + server: "127.0.0.1:7224" }, "error", act_error.ROOM_NOT_EXISTS); await req({ - "authorization": `Digest name=${name1} server=localhost:7224 accountKey=${accountKey}` + "authorization": `Digest name=${name1} server=127.0.0.1:7224 accountKey=${accountKey}` }, "deleteRoom", { room: room2, - server: "localhost:7224" + server: "127.0.0.1:7224" }, "ok", ""); await req({ - "authorization": `Digest name=${name1} server=localhost:7224 accountKey=${accountKey}` + "authorization": `Digest name=${name1} server=127.0.0.1:7224 accountKey=${accountKey}` }, "deleteRoom", { room: room2, - server: "localhost:7224" + server: "127.0.0.1:7224" }, "error", act_error.ROOM_NOT_EXISTS); await req({ - "authorization": `Digest name=${name1} server=localhost:7224 accountKey=${accountKey}` + "authorization": `Digest name=${name1} server=127.0.0.1:7224 accountKey=${accountKey}` }, "listRooms", {}, "ok", [ { name: room1, - server: "localhost:7224", + server: "127.0.0.1:7224", owner: name1, rights: 0b11111, title: "Test Room 1", diff --git a/tests/tests/ws.js b/tests/tests/ws.js index bf77ecf..254faa5 100644 --- a/tests/tests/ws.js +++ b/tests/tests/ws.js @@ -17,33 +17,33 @@ const list = [ ["signup", async (handler, req, newHandler) => { await req(handler, "signup", { name: name1, - server: "localhost:7224", + server: "127.0.0.1:7224", accountKey }, "ok", ""); await req(handler, "signup", { name: name1, - server: "localhost:7224", + server: "127.0.0.1:7224", accountKey }, "error", act_error.WRONG_STATE); await req(await newHandler(), "signup", { name: name1, - server: "localhost:7224", + server: "127.0.0.1:7224", accountKey }, "error", act_error.ACCOUNT_EXISTS); await req(await newHandler(), "signup", { name: name2, - server: "localhost:7224", + server: "127.0.0.1:7224", accountKey }, "ok", ""); await req(await newHandler(), "signup", { name: name3, - server: "localhost:7224", + server: "127.0.0.1:7224", accountKey }, "error", act_error.CONFIG); }], ["remote", async (handler, req, newHandler) => { await req(handler, "signin", { name: name1, - server: "localhost:7224", + server: "127.0.0.1:7224", accountKey }, "ok", ""); let signature = (await req(handler, "createSignature", { @@ -53,25 +53,25 @@ const list = [ let h2 = await newHandler(); await req(h2, "remote1", { name: name1, - server: "localhost:7223", + server: "127.0.0.1:7223", publicKey, sign: signature }, "error", act_error.SIGNATURE); await req(h2, "remote1", { name: name1, - server: "localhost:7224", + server: "127.0.0.1:7224", publicKey, sign: falseSignature }, "error", act_error.SIGNATURE); let challenge = (await req(h2, "remote1", { name: name1, - server: "localhost:7224", + server: "127.0.0.1:7224", publicKey, sign: signature }, "ok", null)).challenge; await req(h2, "remote1", { name: name1, - server: "localhost:7224", + server: "127.0.0.1:7224", publicKey, sign: signature }, "error", act_error.WRONG_STATE); @@ -84,7 +84,7 @@ const list = [ }], ["account", async (handler, req, newHandler) => { await req(handler, "signin", { name: name1, - server: "localhost:7224", + server: "127.0.0.1:7224", accountKey }, "ok", ""); await req(handler, "getMyAccount", {}, "ok", { @@ -98,7 +98,7 @@ const list = [ let h2 = await newHandler(); await req(h2, "signin", { name: name2, - server: "localhost:7224", + server: "127.0.0.1:7224", accountKey }, "ok", ""); await req(h2, "getMyAccount", {}, "ok", { @@ -112,7 +112,7 @@ const list = [ }], ["change account", async (handler, req, newHandler) => { await req(handler, "signin", { name: name2, - server: "localhost:7224", + server: "127.0.0.1:7224", accountKey }, "ok", ""); await req(handler, "changePassword", { @@ -121,12 +121,12 @@ const list = [ let h2 = await newHandler(); await req(h2, "signin", { name: name2, - server: "localhost:7224", + server: "127.0.0.1:7224", accountKey }, "error", act_error.AUTH); await req(h2, "signin", { name: name2, - server: "localhost:7224", + server: "127.0.0.1:7224", accountKey: accountKey + "lol" }, "ok", ""); await req(h2, "deleteAccount", {}, "ok", ""); @@ -134,18 +134,18 @@ const list = [ let h3 = await newHandler(); await req(h3, "signin", { name: name2, - server: "localhost:7224", + server: "127.0.0.1:7224", accountKey: accountKey + "lol" }, "error", act_error.AUTH); }], ["room Owner", async (handler, req, newHandler) => { await req(handler, "signin", { name: name1, - server: "localhost:7224", + server: "127.0.0.1:7224", accountKey }, "ok", ""); await req(handler, "createRoom", { room: room1, - server: "localhost:7224", + server: "127.0.0.1:7224", title: "Test Room 1", description: "some desc", visibility: 0, @@ -153,7 +153,7 @@ const list = [ }, "ok", ""); await req(handler, "createRoom", { room: room1, - server: "localhost:7224", + server: "127.0.0.1:7224", title: "Test Room 1", description: "some desc", visibility: 0, @@ -162,7 +162,7 @@ const list = [ await req(handler, "createRoom", { room: room2, - server: "localhost:7224", + server: "127.0.0.1:7224", title: "Test Room 2", description: "some desc 2", visibility: 1, @@ -171,7 +171,7 @@ const list = [ await req(handler, "createRoom", { room: room3, - server: "localhost:7224", + server: "127.0.0.1:7224", title: "Test Room 2", description: "some desc 2", visibility: 1, @@ -181,7 +181,7 @@ const list = [ await req(handler, "listRooms", {}, "ok", [ { name: room1, - server: "localhost:7224", + server: "127.0.0.1:7224", owner: name1, rights: 0b11111, title: "Test Room 1", @@ -192,7 +192,7 @@ const list = [ confirmed: true }, { name: room2, - server: "localhost:7224", + server: "127.0.0.1:7224", owner: name1, rights: 0b11111, title: "Test Room 2", @@ -205,20 +205,20 @@ const list = [ ]); await req(handler, "deleteRoom", { room: room2 + "lol", - server: "localhost:7224" + server: "127.0.0.1:7224" }, "error", act_error.ROOM_NOT_EXISTS); await req(handler, "deleteRoom", { room: room2, - server: "localhost:7224" + server: "127.0.0.1:7224" }, "ok", ""); await req(handler, "deleteRoom", { room: room2, - server: "localhost:7224" + server: "127.0.0.1:7224" }, "error", act_error.ROOM_NOT_EXISTS); await req(handler, "listRooms", {}, "ok", [ { name: room1, - server: "localhost:7224", + server: "127.0.0.1:7224", owner: name1, rights: 0b11111, title: "Test Room 1",