예제 #1
0
        public async Task CanCreateGetAndDisposeWallet()
        {
            var config = new WalletConfiguration {
                Id = Guid.NewGuid().ToString()
            };
            var creds = new WalletCredentials {
                Key = "1"
            };

            var walletService = new DefaultWalletService();

            await walletService.CreateWalletAsync(config, creds);

            var wallet = await walletService.GetWalletAsync(config, creds);

            Assert.NotNull(wallet);
            Assert.True(wallet.IsOpen);

            wallet.Dispose();

            wallet = await walletService.GetWalletAsync(config, creds);

            Assert.NotNull(wallet);
            Assert.True(wallet.IsOpen);
        }
예제 #2
0
        public async Task ProvisionNewWalletCanUpdateEndpoint()
        {
            var walletService       = new DefaultWalletService();
            var provisioningService = new DefaultProvisioningService(
                new DefaultWalletRecordService(), walletService);

            await provisioningService.ProvisionAgentAsync(new ProvisioningConfiguration
            {
                WalletConfiguration = _config,
                WalletCredentials   = _creds
            });

            var wallet = await walletService.GetWalletAsync(_config, _creds);

            Assert.NotNull(wallet);

            var provisioning = await provisioningService.GetProvisioningAsync(wallet);

            Assert.NotNull(provisioning);
            Assert.Null(provisioning.Endpoint.Uri);

            await provisioningService.UpdateEndpointAsync(wallet, new Models.AgentEndpoint
            {
                Uri = "http://mock"
            });

            provisioning = await provisioningService.GetProvisioningAsync(wallet);

            Assert.NotNull(provisioning);
            Assert.NotNull(provisioning.Endpoint);
            Assert.NotNull(provisioning.Endpoint.Uri);
        }
예제 #3
0
        public async Task ProvisionNewWallet()
        {
            var walletService       = new DefaultWalletService();
            var provisioningService = new DefaultProvisioningService(
                new DefaultWalletRecordService(), walletService);

            var config = new WalletConfiguration {
                Id = Guid.NewGuid().ToString()
            };
            var creds = new WalletCredentials {
                Key = "1"
            };

            await provisioningService.ProvisionAgentAsync(new ProvisioningConfiguration
            {
                WalletConfiguration = config,
                WalletCredentials   = creds,
                EndpointUri         = new Uri("http://mock")
            });

            var wallet = await walletService.GetWalletAsync(config, creds);

            Assert.NotNull(wallet);

            var provisioning = await provisioningService.GetProvisioningAsync(wallet);

            Assert.NotNull(provisioning);
            Assert.NotNull(provisioning.Endpoint);
            Assert.NotNull(provisioning.Endpoint.Did);
            Assert.NotNull(provisioning.Endpoint.Verkey);
        }
예제 #4
0
        public async Task ConcurrentWalletAccess()
        {
            var walletService = new DefaultWalletService();

            var config = new WalletConfiguration {
                Id = Guid.NewGuid().ToString()
            };
            var creds = new WalletCredentials {
                Key = "1"
            };

            await walletService.CreateWalletAsync(config, creds);

            Task <Wallet> openWalletTask1 = walletService.GetWalletAsync(config, creds);
            Task <Wallet> openWalletTask2 = walletService.GetWalletAsync(config, creds);
            Task <Wallet> openWalletTask3 = walletService.GetWalletAsync(config, creds);
            Task <Wallet> openWalletTask4 = walletService.GetWalletAsync(config, creds);

            await Task.WhenAll(openWalletTask1, openWalletTask2, openWalletTask3, openWalletTask4);

            Assert.True(openWalletTask1.Result.IsOpen);
            Assert.True(openWalletTask2.Result.IsOpen);
            Assert.True(openWalletTask3.Result.IsOpen);
            Assert.True(openWalletTask4.Result.IsOpen);
        }
예제 #5
0
        public Task InitializeAsync()
        {
            _walletService       = new DefaultWalletService();
            _provisioningService = new DefaultProvisioningService(
                new DefaultWalletRecordService(), _walletService);

            return(Task.CompletedTask);
        }
예제 #6
0
        public Task InitializeAsync()
        {
            _walletService       = new DefaultWalletService();
            _provisioningService = new DefaultProvisioningService(
                new DefaultWalletRecordService(),
                _walletService,
                Options.Create(new AgentOptions
            {
                WalletConfiguration = _config,
                WalletCredentials   = _creds
            }));

            return(Task.CompletedTask);
        }
예제 #7
0
        public async Task CanCreateWallet_WhenRawKeyDerivationIsUsed()
        {
            var config = new WalletConfiguration {
                Id = Guid.NewGuid().ToString()
            };
            var creds = new WalletCredentials
            {
                Key = await Wallet.GenerateWalletKeyAsync("{}"),
                KeyDerivationMethod = "RAW",
            };

            var walletService = new DefaultWalletService();

            await walletService.CreateWalletAsync(config, creds);

            var wallet = await walletService.GetWalletAsync(config, creds);

            Assert.NotNull(wallet);
            Assert.True(wallet.IsOpen);
        }
예제 #8
0
        public async Task ProvisionNewWalletWithoutEndpoint()
        {
            var walletService       = new DefaultWalletService();
            var provisioningService = new DefaultProvisioningService(
                new DefaultWalletRecordService(), walletService);

            await provisioningService.ProvisionAgentAsync(new BasicProvisioningConfiguration
            {
                WalletConfiguration = _config,
                WalletCredentials   = _creds
            });

            var wallet = await walletService.GetWalletAsync(_config, _creds);

            Assert.NotNull(wallet);

            var provisioning = await provisioningService.GetProvisioningAsync(wallet);

            Assert.NotNull(provisioning);
            Assert.Null(provisioning.Endpoint.Uri);
        }
예제 #9
0
        public async Task CanCreateGetAndDeleteWallet()
        {
            var config = new WalletConfiguration {
                Id = Guid.NewGuid().ToString()
            };
            var creds = new WalletCredentials {
                Key = "1"
            };

            var walletService = new DefaultWalletService();

            await walletService.CreateWalletAsync(config, creds);

            var wallet = await walletService.GetWalletAsync(config, creds);

            Assert.NotNull(wallet);
            Assert.True(wallet.IsOpen);

            await walletService.DeleteWalletAsync(config, creds);

            await Assert.ThrowsAsync <WalletNotFoundException>(() => walletService.GetWalletAsync(config, creds));
        }
예제 #10
0
 public async Task InitializeAsync()
 {
     _walletService       = new DefaultWalletService();
     _provisioningService = new DefaultProvisioningService(
         new DefaultWalletRecordService(), _walletService);
 }