installTestEncryptionKey function

void installTestEncryptionKey()

Installs the per-run test encryption key and clears the cached key.

Implementation

void installTestEncryptionKey() {
  final fromDefine =
      RunnerRuntimeConfiguration.current.string('ensembleTestEncryptionKey');
  final key = fromDefine.isNotEmpty ? fromDefine : _fallbackTestEncryptionKey();
  if (key.length != 32) {
    throw StateError(
      'ensembleTestEncryptionKey must be exactly 32 characters '
      '(got ${key.length}).',
    );
  }
  EncryptedStorageManager.resetCachedKey();
  SecretsStore().secretCache['encryptionKey'] = key;
}