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 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 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(); }