public OASISAPIManager(List <IOASISProvider> OASISProviders, bool startApolloServer = true) //public OASISAPIManager() { ProviderManager.RegisterProviders(OASISProviders); //TODO: Soon you will not need to pass these in since MEF will taKe care of this for us. this.MapManager = new MapManager(); // TODO: Soon you will not need to inject in a provider because the mappings below will be used instead... this.ProfileManager = new ProfileManager(ProviderManager.GetStorageProvider(ProviderType.HoloOASIS)); //TODO: Move the mappings to an external config wrapper than is injected into the OASISAPIManager constructor above... // Give HoloOASIS Store permission for the Name field (the field will only be stored on Holochain). this.ProfileManager.Config.FieldToProviderMappings.Name.Add(new ProfileManagerConfig.FieldToProviderMappingAccess { Access = ProfileManagerConfig.ProviderAccess.Store, Provider = ProviderType.HoloOASIS }); // Give all providers read/write access to the Name field (will allow them to read and write to the field but it will only be stored on Holochain). // You could choose to store it on more than one provider if you wanted the extra redundancy (but not normally needed since Holochain has a lot of redundancy built in). this.ProfileManager.Config.FieldToProviderMappings.Name.Add(new ProfileManagerConfig.FieldToProviderMappingAccess { Access = ProfileManagerConfig.ProviderAccess.ReadWrite, Provider = ProviderType.All }); //this.ProfileManager.Config.FieldToProviderMappings.Name.Add(new ProfileManagerConfig.FieldToProviderMappingAccess { Access = ProfileManagerConfig.ProviderAccess.ReadWrite, Provider = ProviderType.EthereumOASIS }); //this.ProfileManager.Config.FieldToProviderMappings.Name.Add(new ProfileManagerConfig.FieldToProviderMappingAccess { Access = ProfileManagerConfig.ProviderAccess.ReadWrite, Provider = ProviderType.IPFSOASIS }); //this.ProfileManager.Config.FieldToProviderMappings.DOB.Add(new ProfileManagerConfig.FieldToProviderMappingAccess { Access = ProfileManagerConfig.ProviderAccess.Store, Provider = ProviderType.HoloOASIS }); //Give Ethereum read-only access to the DOB field. this.ProfileManager.Config.FieldToProviderMappings.DOB.Add(new ProfileManagerConfig.FieldToProviderMappingAccess { Access = ProfileManagerConfig.ProviderAccess.ReadOnly, Provider = ProviderType.EthereumOASIS }); if (startApolloServer) { ApolloServer.StartServer(); } }
public async Task Alias__requesting_an_unowned_alias() { var uk123Token = Guid.NewGuid(); using (var service = new MockService(_logger)) { var serverStorage = new InMemoryApolloServerRepository(); var client = new ApolloClient(new MockServiceCommunicator("Client1", service, _logger)); var server = new ApolloServer(new MockServiceCommunicator("Server1", service, _logger), serverStorage); (await client.RegisterAsync()).Should().NotBeNullOrEmpty(); (await client.RequestOwnershipOfAliasAsync("UK123", uk123Token)).Should().Be(uk123Token); } }
public async Task Ping__ping_the_server() { using (var service = new MockService(_logger)) { var serverStorage = new InMemoryApolloServerRepository(); var client1 = new ApolloClient(new MockServiceCommunicator("Client1", service, _logger)); var server = new ApolloServer(new MockServiceCommunicator("Server1", service, _logger), serverStorage); (await client1.RegisterAsync()).Should().NotBeNullOrEmpty(); var result = await client1.GetPlugin <ClientCorePlugin>().PingServer(); result.RethrowCaughtException(); result.Result.Should().Be(PingStats.PingResult.Success); } }
static void Main(string[] args) { Console.WriteLine("NEXTGEN SOFTWARE OASIS API APOLLO SERVER TEST HARNESS V1.0"); Console.WriteLine(""); Console.WriteLine("Starting Server..."); ApolloServer.StartServer(); Console.WriteLine("Server Started."); Console.WriteLine("Press any key to shutdown the server..."); Console.ReadKey(); Console.WriteLine("Shutting Down The Server..."); ApolloServer.ShutdownServer(); Console.WriteLine("Server Shutdown."); }
public async Task Registration__metadata_should_be_stored_by_the_server() { using (var service = new MockService(_logger)) { var serverStorage = new InMemoryApolloServerRepository(); var client = new ApolloClient(new MockServiceCommunicator("Client1", service, _logger)); var server = new ApolloServer(new MockServiceCommunicator("Server1", service, _logger), serverStorage); await client.RegisterAsync(new Dictionary <string, string> { { "Answer", "Bloop" } }); serverStorage.LoadRegistration("Client1") .Should() .Contain(new KeyValuePair <string, string>("Answer", "Bloop")); } }
public async Task Alias__requesting_an_already_owned_alias() { var uk123Token = Guid.NewGuid(); using (var service = new MockService(_logger)) { var serverStorage = new InMemoryApolloServerRepository(); var client1 = new ApolloClient(new MockServiceCommunicator("Client1", service, _logger)); var client2 = new ApolloClient(new MockServiceCommunicator("Client2", service, _logger)); var server = new ApolloServer(new MockServiceCommunicator("Server1", service, _logger), serverStorage); (await client1.RegisterAsync()).Should().NotBeNullOrEmpty(); (await client2.RegisterAsync()).Should().NotBeNullOrEmpty(); (await client1.RequestOwnershipOfAliasAsync("UK123", uk123Token)).Should().Be(uk123Token, "client 1 was the first to request ownership of UK123"); (await client2.RequestOwnershipOfAliasAsync("UK123", Guid.NewGuid())).Should().Be(Guid.Empty, "client 1 already owns UK123"); } }
public async Task Ping__ping_an_unowned_alias() { var practiceId = "UK123"; using (var service = new MockService(_logger)) { var serverStorage = new InMemoryApolloServerRepository(); var client1 = new ApolloClient(new MockServiceCommunicator("Client1", service, _logger)); var client2 = new ApolloClient(new MockServiceCommunicator("Client2", service, _logger)); var server = new ApolloServer(new MockServiceCommunicator("Server1", service, _logger), serverStorage); (await client1.RegisterAsync()).Should().NotBeNullOrEmpty(); (await client2.RegisterAsync()).Should().NotBeNullOrEmpty(); var result = await client1.GetPlugin <ClientCorePlugin>().PingAlias(practiceId); result.RethrowCaughtException(); result.Result.Should().Be(PingStats.PingResult.AddresseeNotFound); } }
public async Task Ping__ping_an_alias() { var client1Token = Guid.NewGuid(); var practiceId = "UK123"; using (var service = new MockService(_logger)) { var serverStorage = new InMemoryApolloServerRepository(); var client1 = new ApolloClient(new MockServiceCommunicator("Client1", service, _logger)); var client2 = new ApolloClient(new MockServiceCommunicator("Client2", service, _logger)); var server = new ApolloServer(new MockServiceCommunicator("Server1", service, _logger), serverStorage); (await client1.RegisterAsync()).Should().NotBeNullOrEmpty(); (await client2.RegisterAsync()).Should().NotBeNullOrEmpty(); (await client1.RequestOwnershipOfAliasAsync(practiceId, client1Token)).Should().Be(client1Token, "client 1 was the first to request ownership of UK123"); var result = await client1.GetPlugin <ClientCorePlugin>().PingAlias(practiceId); result.RethrowCaughtException(); result.Result.Should().Be(PingStats.PingResult.Success); } }
public async Task Alias__taking_an_already_owned_alias() { var client1Token = Guid.NewGuid(); var client2Token = Guid.NewGuid(); var practiceId = "UK123"; using (var service = new MockService(_logger)) { var serverStorage = new InMemoryApolloServerRepository(); var client1 = new ApolloClient(new MockServiceCommunicator("Client1", service, _logger)); var client2 = new ApolloClient(new MockServiceCommunicator("Client2", service, _logger)); var server = new ApolloServer(new MockServiceCommunicator("Server1", service, _logger), serverStorage); (await client1.RegisterAsync()).Should().NotBeNullOrEmpty(); (await client2.RegisterAsync()).Should().NotBeNullOrEmpty(); (await client1.RequestOwnershipOfAliasAsync(practiceId, client1Token)).Should().Be(client1Token, "client 1 was the first to request ownership of UK123"); (await client2.RequestOwnershipOfAliasAsync(practiceId, client2Token)).Should().Be(Guid.Empty, "client 1 already owns UK123"); (await client2.DemandOwnershipOfAliasAsync(practiceId, client2Token)).Should().Be(client2Token, "client 2 should be able to steal ownership of UK123"); (await client1.RequestOwnershipOfAliasAsync(practiceId, client1Token)).Should().Be(Guid.Empty, "client 1 no longer owns UK123"); (await client2.RequestOwnershipOfAliasAsync(practiceId, client2Token)).Should().Be(client2Token, "client 2 now owns UK123"); } }