Files
orca/cloud/dev/scripts/read-relay-production-capacity-identity.test.mjs
T
Jinwoo Hong 3eec77c11a chore(cloud): add the relay fence broker, ops console, Terraform root, scripts, and 24 cloud-* workflows (#18413)
Phase 6 of the relay split: the relay's deploy/operate surface moves under cloud/ with 24 cloud-* workflows gated on ORCA_CLOUD_OPERATIONS_ENABLED, the Cloud SQL rollout lease action, the relay Terraform root (dual-accept identities for both repositories), scripts, docs, CODEOWNERS, and a terraform validate job in Cloud Verify.
2026-09-03 06:55:14 -04:00

45 lines
1.5 KiB
JavaScript

import assert from 'node:assert/strict'
import test from 'node:test'
import { readProductionCapacityIdentity } from './read-relay-production-capacity-identity.mjs'
function revision(env) {
return { spec: { containers: [{ env }] } }
}
test('reads absent, exact, and foreign literal capacity identities', () => {
assert.equal(readProductionCapacityIdentity(revision([])), null)
assert.equal(
readProductionCapacityIdentity(revision([
{ name: 'ORCA_RELAY_CAPACITY_SERVICE_ACCOUNT', value: 'capacity@example.test' }
])),
'capacity@example.test'
)
assert.equal(
readProductionCapacityIdentity(revision([
{ name: 'ORCA_RELAY_CAPACITY_SERVICE_ACCOUNT', value: 'foreign@example.test' }
])),
'foreign@example.test'
)
})
test('rejects malformed or duplicate capacity identity entries', () => {
for (const entry of [
{ name: 'ORCA_RELAY_CAPACITY_SERVICE_ACCOUNT', value: null },
{ name: 'ORCA_RELAY_CAPACITY_SERVICE_ACCOUNT', value: '' },
{ name: 'ORCA_RELAY_CAPACITY_SERVICE_ACCOUNT', valueSource: { secretKeyRef: {} } }
]) {
assert.throws(
() => readProductionCapacityIdentity(revision([entry])),
/not a literal string/
)
}
assert.throws(
() => readProductionCapacityIdentity(revision([
{ name: 'ORCA_RELAY_CAPACITY_SERVICE_ACCOUNT', value: 'one@example.test' },
{ name: 'ORCA_RELAY_CAPACITY_SERVICE_ACCOUNT', value: 'two@example.test' }
])),
/duplicate capacity identity/
)
assert.throws(() => readProductionCapacityIdentity({}), /environment is missing/)
})