'use strict';

const assert = require('assert');
const path = require('path');
const policy = require(path.join(__dirname, '..', 'config', 'serviceMediaReplication.example.json'));

assert.equal(policy.schemaVersion, 'plai-service-media-replication-policy/v1');
assert.equal(policy.activationAllowed, false);
assert.equal(policy.sourceServices.length, 5);
assert.equal(policy.encryption.requiredBeforeExternalNodeTransfer, true);
assert.equal(policy.encryption.storageNodeReceivesPlaintext, false);
assert.equal(policy.encryption.storageNodeReceivesDecryptionKey, false);
assert.ok(policy.placement.minimumCiphertextReplicas >= 3);
assert.ok(policy.placement.minimumIndependentFailureDomains >= 3);
assert.equal(policy.placement.maximumReplicasPerFailureDomain, 1);
assert.equal(policy.placement.fixedNodeAllowlistAllowed, false);
assert.equal(policy.placement.unexpiredCapabilityLeaseRequired, true);
assert.ok(policy.liveness.maximumHeartbeatAgeSeconds <= 180);
assert.ok(policy.repair.minimumPeerVotes >= 3);
assert.ok(policy.repair.minimumVoteFailureDomains >= 2);
assert.ok(policy.repair.fencingLeaseMaximumSeconds <= 180);
assert.equal(policy.repair.plaintextRepairAllowed, false);
assert.equal(policy.restore.signedManifestRequired, true);
assert.ok(policy.restore.minimumManifestVotes >= 3);
assert.equal(policy.restore.ciphertextHashVerificationRequired, true);
assert.equal(policy.deletion.signedTombstoneRequired, true);
assert.equal(policy.deletion.physicalDeletionBeforeFinalityAllowed, false);
assert.deepEqual(policy.production, {
  readsAllowed: false,
  writesAllowed: false,
  externalTransfersAllowed: false,
  dnsChangesAllowed: false
});

console.log(JSON.stringify({
  ok: true,
  status: 'SERVICE_MEDIA_CIPHERTEXT_THREE_DOMAIN_POLICY_STAGED_DEFAULT_OFF',
  sourceServices: policy.sourceServices.length,
  minimumCiphertextReplicas: policy.placement.minimumCiphertextReplicas,
  minimumIndependentFailureDomains: policy.placement.minimumIndependentFailureDomains,
  activationAllowed: policy.activationAllowed,
  productionChanged: false
}, null, 2));
