public void CanLogInWithJwt() { var dataApiClient = new DataApiClient(ApiSetup.ApiConfiguration); Assume.That(dataApiClient.IsLoggedIn, Is.False); Assume.That(dataApiClient.LoggedInUsername, Is.Null); Assume.That(dataApiClient.IsAvailable()); try { dataApiClient.Register("Test_sdfrgnbfgfdgj", "fgjerg", "sadfgfg", "egjdfbednbrgeo", "*****@*****.**"); } catch (ApiException apiException) { if (apiException.StatusCode != HttpStatusCode.Conflict) { throw; } } var authenticationResult = dataApiClient.Login("Test_sdfrgnbfgfdgj", "egjdfbednbrgeo"); Assert.That(authenticationResult, Is.Not.Null); Assert.That(authenticationResult.IsAuthenticated, Is.True); Assert.That(dataApiClient.IsLoggedIn, Is.True); Assert.That(dataApiClient.LoggedInUsername, Is.EqualTo("test_sdfrgnbfgfdgj")); Assert.That(() => authenticationResult = dataApiClient.Login("invalidUser", "invalidPassword"), Throws.Nothing); Assert.That(authenticationResult.IsAuthenticated, Is.False); }
public void CanRegisterLoginAndDeleteUser() { Assume.That(adminDataApiClient.IsAvailable(), "API not available"); var dataApiClient = new DataApiClient(ApiSetup.ApiConfiguration); var username = UserGenerator.GenerateUsername(); var password = UserGenerator.GeneratePassword(); var email = $"{username}@example.org"; var firstName = "Jamie"; var lastName = "Doe"; Assert.That(() => dataApiClient.Register(username, firstName, lastName, password, email), Throws.Nothing); AuthenticationResult authenticationResult = null; Assert.That(() => authenticationResult = dataApiClient.Login(username, password), Throws.Nothing); Assert.That(authenticationResult.IsAuthenticated, Is.True); Assert.That(() => dataApiClient.DeleteUser(username), Throws.Nothing); dataApiClient.Logout(); Assert.That(() => authenticationResult = dataApiClient.Login(username, password), Throws.Nothing); Assert.That(authenticationResult.IsAuthenticated, Is.False); }
public static AuthenticationResult RegisterAndLoginUserWithoutRoles(out IDataApiClient dataApiClient) { var username = GenerateUsername(); var password = GeneratePassword(); var email = $"{username}@example.org"; var firstName = "Jamie"; var lastName = "Doe"; dataApiClient = new DataApiClient(ApiSetup.ApiConfiguration); dataApiClient.Register(username, firstName, lastName, password, email); return(dataApiClient.Login(username, password)); }
public async Task DownloadFileReturnsFilename() { var dataApiClient = new DataApiClient(ApiSetup.ApiConfiguration); dataApiClient.Login(); var actual = await dataApiClient.Download("DataBlob", "DCF9C0E1FD926E2C6B5E4E9E18001B3F00EEB30B"); Assert.That(actual.Filename, Is.EqualTo("excelReferenceCache.json")); var data = ToByteArray(actual.Stream); Assert.That(data, Is.Not.Empty); }
public void CanLogInWithActiveDirectory() { var dataApiClient = new DataApiClient(ApiSetup.ApiConfiguration); Assume.That(dataApiClient.IsAvailable()); Assume.That(dataApiClient.IsLoggedIn, Is.False); Assume.That(dataApiClient.LoggedInUsername, Is.Null); //Assert.That(() => dataApiClient.Login("Test_sdfrgnbfgfdgj", "egjdfbednbrgeo"), Throws.Nothing); var authenticationResult = dataApiClient.Login(); Assert.That(authenticationResult, Is.Not.Null); Assert.That(authenticationResult.IsAuthenticated, Is.True); Assert.That(dataApiClient.IsLoggedIn, Is.True); Assert.That(dataApiClient.LoggedInUsername, Is.EqualTo("jdoe")); }
private async void App_OnStartup(object sender, StartupEventArgs e) { StaticUiUpdateNotifier.Notifier = new WpfUiUpdateNotifier(); StaticMessageBoxSpawner.Spawner = new WpfMessageBoxSpawner(); var dataApiClient = new DataApiClient(new ApiConfiguration(Settings.Default.ApiServerAddress, Settings.Default.ApiServerPort)); dataApiClient.Login(); if (!dataApiClient.IsLoggedIn) { StaticMessageBoxSpawner.Show("Could not log into DataAPI. Shutting down..."); Shutdown(-1); return; } var permissionCheckerResult = await DataPermissionChecker.Check(dataApiClient, new Dictionary <string, IList <Role> > { { nameof(DataServiceDefinition), new List <Role> { Role.Viewer, Role.DataProducer } }, { nameof(IDataServiceTarget), new List <Role> { Role.Viewer, Role.DataProducer } } }); if (!permissionCheckerResult.HasSufficientPermissions) { StaticMessageBoxSpawner.Show("You don't have enough permissions on the DataAPI to run this application. Please contact Inno-IT."); Shutdown(-1); return; } var dataServiceDefinitionDatabase = new GenericDatabase <DataServiceDefinition>(dataApiClient); var dataTypeList = new DataApiDataTypeList(dataApiClient); var usernameProxy = new DataApiUsernameProxy(dataApiClient); var sqlExpressionValidator = new SqlExpressionValidator(dataApiClient); var mainWindow = new MainWindow(); var mainViewModel = new MainViewModel( dataApiClient, dataServiceDefinitionDatabase, mainWindow, dataTypeList, usernameProxy, sqlExpressionValidator); mainWindow.ViewModel = mainViewModel; mainWindow.ShowDialog(); }
private void App_OnStartup(object sender, StartupEventArgs e) { StaticMessageBoxSpawner.Spawner = new WpfMessageBoxSpawner(); StaticUiUpdateNotifier.Notifier = new WpfUiUpdateNotifier(); var apiConfiguration = new ApiConfiguration(Settings.Default.ApiServerAddress, Settings.Default.ApiServerPort); var dataApiClient = new DataApiClient(apiConfiguration); if (!dataApiClient.IsAvailable()) { MessageBox.Show($"Cannot contact DataAPI @ '{apiConfiguration.ServerAddress}:{apiConfiguration.ServerPort}'. Shutting down..."); Current.Shutdown(-1); return; } try { dataApiClient.Login(); } catch { // Ignore. If Active Directory is not available, in some other way later. } var dataVisualizer = new DataVisualizer(new IDataVisualizationViewModelFactory[] { new ImageVisualizationViewModelFactory(dataApiClient), // TODO: Add more entries here to custom visualization for data types }); var userDatabase = new UserDatabase(dataApiClient); var dataSetDatabase = new GenericDatabase <DataSet>(dataApiClient); var dataProjectDatabase = new GenericDatabase <DataProject>(dataApiClient); var clipboard = new WpfClipboard(); var mainWindow = new MainWindow(); var mainViewModel = new MainViewModel( dataApiClient, dataVisualizer, userDatabase, dataSetDatabase, dataProjectDatabase, clipboard, mainWindow); mainWindow.ViewModel = mainViewModel; mainWindow.ShowDialog(); }
private void App_OnStartup(object sender, StartupEventArgs e) { Current.ShutdownMode = ShutdownMode.OnExplicitShutdown; StaticMessageBoxSpawner.Spawner = new WpfMessageBoxSpawner(); StaticUiUpdateNotifier.Notifier = new WpfUiUpdateNotifier(); var apiConfiguration = new ApiConfiguration(Settings.Default.DataApiServerAddress, Settings.Default.DataApiServerPort); var dataApiClient = new DataApiClient(apiConfiguration); if (!dataApiClient.IsAvailable()) { MessageBox.Show($"Cannot contact DataAPI @ '{apiConfiguration.ServerAddress}:{apiConfiguration.ServerPort}'. Shutting down..."); Current.Shutdown(-1); return; } try { dataApiClient.Login(); } catch { // Ignore. If Active Directory is not available, in some other way later. } var logEntryMonitor = new LogEntryMonitor(dataApiClient); var mainWindow = new MainWindow(); var mainViewModel = new MainViewModel(dataApiClient, logEntryMonitor, mainWindow); mainWindow.ViewModel = mainViewModel; try { mainWindow.ShowDialog(); } catch (Exception exception) { MessageBox.Show(exception.ToString()); throw; } // Shutdown logEntryMonitor.StopMonitoring(); Shutdown(0); }
private void App_OnStartup(object sender, StartupEventArgs e) { StaticMessageBoxSpawner.Spawner = new WpfMessageBoxSpawner(); StaticUiUpdateNotifier.Notifier = new WpfUiUpdateNotifier(); var clipboard = new WpfClipboard(); var startWindow = new StartupWindow { ApplicationName = "File uploader" }; startWindow.Show(); var apiConfiguration = new ApiConfiguration( Settings.Default.ApiServerAddress, Settings.Default.ApiServerPort); var dataApiClient = new DataApiClient(apiConfiguration); if (!dataApiClient.IsAvailable()) { MessageBox.Show($"Cannot contact DataAPI @ '{apiConfiguration.ServerAddress}:{apiConfiguration.ServerPort}'. Shutting down..."); Current.Shutdown(-1); return; } try { dataApiClient.Login(); } catch { // Ignore. If Active Directory is not available, in some other way later. } var imageDatabase = new GenericDatabase <Image>(dataApiClient); var shortIdDatabase = new GenericDatabase <ShortId>(dataApiClient); var dataSetDatabase = new GenericDatabase <DataSet>(dataApiClient); var tagDatabase = new GenericDatabase <DataTag>(dataApiClient); var projectDatabase = new GenericDatabase <DataProject>(dataApiClient); var protocolDatabase = new GenericDatabase <DataCollectionProtocol>(dataApiClient); var protocolParameterDatabase = new GenericDatabase <DataCollectionProtocolParameter>(dataApiClient); var dataBlobDatabase = new GenericDatabase <DataBlob>(dataApiClient); var dataProjectUploadInfoDatabase = new GenericDatabase <DataProjectUploadInfo>(dataApiClient); var fileHandlers = new IFileHandler[] { new ImageFileHandler(imageDatabase) }; var additionalInformationViewSpawner = new WpfAdditionalInformationViewSpawner(); var fileManager = new UploadedFileProcessor( fileHandlers, dataApiClient, dataBlobDatabase, dataProjectUploadInfoDatabase, clipboard, additionalInformationViewSpawner); var mainWindow = new MainWindow(); var mainViewModel = new MainViewModel( mainWindow, dataApiClient, fileManager, dataSetDatabase, tagDatabase, projectDatabase, protocolDatabase, protocolParameterDatabase); mainWindow.ViewModel = mainViewModel; startWindow.Close(); mainWindow.ShowDialog(); }
protected ApiTestBase() { DataApiClient = new DataApiClient(ApiSetup.ApiConfiguration); DataApiClient.Login(ApiSetup.UnitTestAdminUsername, ApiSetup.UnitTestAdminPassword); }