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);
        }
        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);
        }
        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);
        }
Example #4
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);
        }
        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));
        }
Example #6
0
        public async Task ProvisionNewWalletWithEndpoint()
        {
            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);
        }
Example #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);
        }
Example #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);
        }