Skip to content

Commit

Permalink
test: assert public key format & length (#430)
Browse files Browse the repository at this point in the history
Signed-off-by: Miroslav Bajtoš <[email protected]>
  • Loading branch information
bajtos authored Apr 26, 2024
1 parent 1a52c7b commit 2e298e8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/station-id.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ describe('station-id', () => {
assert.deepStrictEqual(loaded, generated)
})

it('returns a public key that is exactly 88 characters long', async () => {
// spark-api is enforcing this constraint and rejecting measurements containing stationId
// in a different format
const secretsDir = getUniqueTempDir()
const { publicKey } = await await getStationId({ secretsDir, passphrase: 'secret' })
assert.strictEqual(publicKey.length, 88, 'publicKey.length')
assert.match(publicKey, /^[0-9A-Za-z]*$/)
})

it('skips encryption when passphrase is not set', async () => {
const secretsDir = getUniqueTempDir()
const generated = await getStationId({ secretsDir, passphrase: '' })
Expand Down

0 comments on commit 2e298e8

Please sign in to comment.