diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index 081a3f939..46799747c 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -96,3 +96,13 @@ jobs: concurrency: group: ${{ github.workflow }}-clock-rocks-${{ github.ref || github.run_id }} cancel-in-progress: true + + e2e-admin-password: + name: E2E Admin Password + uses: ./.github/workflows/_setup-e2e.yml + with: + justfile_recipe: "e2e-admin-password" + + concurrency: + group: ${{ github.workflow }}-admin-password-${{ github.ref || github.run_id }} + cancel-in-progress: true diff --git a/e2e/test/admin/e2e-admin-password-enabled.test.ts b/e2e/test/admin/e2e-admin-password-enabled.test.ts index c8d25417a..d68e5f143 100644 --- a/e2e/test/admin/e2e-admin-password-enabled.test.ts +++ b/e2e/test/admin/e2e-admin-password-enabled.test.ts @@ -8,15 +8,16 @@ describe("Admin Password (with password set)", () => { it("should reject requests without password", async () => { const error = await sendAndGetError("stratus_enableTransactions", []); - expect(error.code).eq(-32603); // Internal error - expect(error.message).to.contain("Invalid password"); + console.log(error); + expect(error.code).eq(-32009); // Internal error + expect(error.message).to.contain("Incorrect password"); }); it("should reject requests with wrong password", async () => { const headers = { Authorization: "Password wrong123" }; const error = await sendAndGetError("stratus_enableTransactions", [], headers); - expect(error.code).eq(-32603); // Internal error - expect(error.message).to.contain("Invalid password"); + expect(error.code).eq(-32009); // Internal error + expect(error.message).to.contain("Incorrect password"); }); it("should accept requests with correct password", async () => { diff --git a/e2e/test/external/e2e-admin-password.test.ts b/e2e/test/external/e2e-admin-password.test.ts deleted file mode 100644 index bfc509a34..000000000 --- a/e2e/test/external/e2e-admin-password.test.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { expect } from "chai"; -import { send, sendAndGetError, sendReset } from "../helpers/rpc"; - -describe("Admin Password", () => { - describe("With ADMIN_PASSWORD set", () => { - before(async () => { - await sendReset(); - }); - - it("should reject requests without password", async () => { - const error = await sendAndGetError("stratus_enableTransactions", []); - expect(error.code).eq(-32603); // Internal error - expect(error.message).to.contain("Invalid password"); - }); - - it("should reject requests with wrong password", async () => { - const headers = { Authorization: "Password wrong123" }; - const error = await sendAndGetError("stratus_enableTransactions", [], headers); - expect(error.code).eq(-32603); // Internal error - expect(error.message).to.contain("Invalid password"); - }); - - it("should accept requests with correct password", async () => { - const headers = { Authorization: "Password test123" }; - const result = await send("stratus_enableTransactions", [], headers); - expect(result).to.be.true; - - // Cleanup - disable transactions - await send("stratus_disableTransactions", [], headers); - }); - }); - - describe("Without ADMIN_PASSWORD set", () => { - before(async () => { - delete process.env.ADMIN_PASSWORD; - await sendReset(); - }); - - it("should accept requests without password", async () => { - const result = await send("stratus_enableTransactions", []); - expect(result).to.be.true; - - // Cleanup - disable transactions - await send("stratus_disableTransactions", []); - }); - - it("should accept requests with any password", async () => { - const headers = { Authorization: "Password random123" }; - const result = await send("stratus_enableTransactions", [], headers); - expect(result).to.be.true; - - // Cleanup - disable transactions - await send("stratus_disableTransactions", [], headers); - }); - }); -}); diff --git a/src/eth/rpc/rpc_http_middleware.rs b/src/eth/rpc/rpc_http_middleware.rs index 84b2eb7e9..941ed40bf 100644 --- a/src/eth/rpc/rpc_http_middleware.rs +++ b/src/eth/rpc/rpc_http_middleware.rs @@ -54,9 +54,9 @@ pub enum Authentication { impl Authentication { pub fn auth_admin(&self) -> Result<(), StratusError> { if matches!(self, Authentication::Admin) { - return Err(StratusError::InvalidPassword); + return Ok(()) } - Ok(()) + Err(StratusError::InvalidPassword) } }