-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: RPC: Check for passwords in admin endpoints (#1921)
- Loading branch information
1 parent
7b595d9
commit 08cc4e5
Showing
11 changed files
with
194 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { expect } from "chai"; | ||
|
||
import { send, sendReset } from "../helpers/rpc"; | ||
|
||
describe("Admin Password (without password set)", () => { | ||
before(async () => { | ||
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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { expect } from "chai"; | ||
|
||
import { send, sendAndGetError, sendReset } from "../helpers/rpc"; | ||
|
||
describe("Admin Password (with password set)", () => { | ||
before(async () => { | ||
await sendReset(); | ||
}); | ||
|
||
it("should reject requests without password", async () => { | ||
const error = await sendAndGetError("stratus_enableTransactions", []); | ||
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(-32009); // Internal error | ||
expect(error.message).to.contain("Incorrect 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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters