Beispiel #1
0
 public MongoDbClientStoreTests(MongoSetup mongoSetup) : base(mongoSetup)
 {
     _migrator       = A.Fake <IClientStoreMigrator>();
     _collectionName = "clients_" + Guid.NewGuid();
     _encryptionKey  = new SharedSecretEncryptionKey("The_Big_Secret");
     _signatureAlgorithmDataRecordConverter = new SignatureAlgorithmDataRecordConverter(new FakeStringProtectorFactory());
     _sut = new MongoDbClientStore(new MongoDatabaseClientProvider(Database), _collectionName, _encryptionKey, _migrator, _signatureAlgorithmDataRecordConverter);
 }
Beispiel #2
0
 public FileSystemClientStore(
     IFileManager <ClientDataRecord> fileManager,
     ISignatureAlgorithmDataRecordConverter signatureAlgorithmDataRecordConverter,
     SharedSecretEncryptionKey encryptionKey)
 {
     _fileManager = fileManager ?? throw new ArgumentNullException(nameof(fileManager));
     _signatureAlgorithmDataRecordConverter = signatureAlgorithmDataRecordConverter ?? throw new ArgumentNullException(nameof(signatureAlgorithmDataRecordConverter));
     _encryptionKey = encryptionKey;
 }
        public FileSystemClientStoreTests()
        {
            var tempFilePath = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".xml");

            _fileManager = new ClientsFileManager(
                new FileReader(),
                new FileWriter(),
                tempFilePath,
                new ClientDataRecordSerializer());
            var encryptionKey = new SharedSecretEncryptionKey("The_Big_Secret");

            _signatureAlgorithmDataRecordConverter = new SignatureAlgorithmDataRecordConverter(new FakeStringProtectorFactory());
            _sut = new FileSystemClientStore(_fileManager, _signatureAlgorithmDataRecordConverter, encryptionKey);
        }
        public MongoDbClientStore(
            IMongoDatabaseClientProvider clientProvider,
            string collectionName,
            SharedSecretEncryptionKey encryptionKey,
            IClientStoreMigrator migrator,
            ISignatureAlgorithmDataRecordConverter signatureAlgorithmDataRecordConverter)
        {
            if (clientProvider == null)
            {
                throw new ArgumentNullException(nameof(clientProvider));
            }
            if (string.IsNullOrEmpty(collectionName))
            {
                throw new ArgumentException("Value cannot be null or empty.", nameof(collectionName));
            }
            _encryptionKey = encryptionKey;
            _migrator      = migrator ?? throw new ArgumentNullException(nameof(migrator));
            _signatureAlgorithmDataRecordConverter = signatureAlgorithmDataRecordConverter ?? throw new ArgumentNullException(nameof(signatureAlgorithmDataRecordConverter));

            _lazyCollection = new Lazy <IMongoCollection <ClientDataRecordV2> >(() => {
                var database = clientProvider.Provide();
                return(database.GetCollection <ClientDataRecordV2>(collectionName));
            });
        }