Skip to content

Commit

Permalink
fix, and add test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
carneiro-cw committed Dec 20, 2024
1 parent 3290325 commit 0b25e87
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 62 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 5 additions & 4 deletions e2e/test/admin/e2e-admin-password-enabled.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
56 changes: 0 additions & 56 deletions e2e/test/external/e2e-admin-password.test.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/eth/rpc/rpc_http_middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down

0 comments on commit 0b25e87

Please sign in to comment.