private async Task GetApplications() { try { if (string.IsNullOrWhiteSpace(ConfigurationManager.Current.ApiKey)) { AskApiKeyForm form = new AskApiKeyForm(ConfigurationManager.Current.ApiKey); form.ShowDialog(); if (string.IsNullOrWhiteSpace(form.ApiKey)) { MessageBox.Show("No API Key. Application will exit."); this.Close(); } } settingsManager = new SettingsAPIClient.SettingsManager(ConfigurationManager.Current.Url, ConfigurationManager.Current.ApiKey); IEnumerable <SettingsApplication> applications = null; try { applications = await settingsManager.GetApplications(); } catch (AggregateException ex) { MessageBox.Show(ex.InnerException.Message); } gridControl1.DataSource = applications.ToList(); } catch (SettingsException ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public VersionsForm(string applicationName) { InitializeComponent(); this.settingsManager = new SettingsAPIClient.SettingsManager(ConfigurationManager.Current.Url, ConfigurationManager.Current.ApiKey); this.Shown += VersionsForm_Shown; this.applicationName = applicationName; Task.Run(() => LoadApplication()); gridViewVersions.DoubleClick += GridViewVersions_DoubleClick; }
public VersionsForm(string applicationName) { InitializeComponent(); this.settingsManager = new SettingsAPIClient.SettingsManager(ConfigurationManager.Current.Url, ConfigurationManager.Current.ApiKey); this.Shown += VersionsForm_Shown; this.applicationName = applicationName; Task.Run(() => LoadApplication()); gridViewVersions.DoubleClick += GridViewVersions_DoubleClick; }
public void OpenWrongStoreUrl() { try { settingsManager = new SettingsManager("123123", "123"); } catch (SettingsException) { } }
public ApplicationEditForm(SettingsApplication application, SettingsAPIClient.SettingsManager settingsManager) { InitializeComponent(); this.settingsManager = settingsManager; this.application = application; if (application != null) { textName.Text = application.Name; textDescription.Text = application.Description; } }
public ApplicationEditForm(SettingsApplication application, SettingsAPIClient.SettingsManager settingsManager) { InitializeComponent(); this.settingsManager = settingsManager; this.application = application; if(application != null) { textName.Text = application.Name; textDescription.Text = application.Description; } }
public DirectoryEditForm(SettingsDirectory directory, string applicationName) { InitializeComponent(); this._directory = directory; this._applicationName = applicationName; this.settingsManager = new SettingsAPIClient.SettingsManager(ConfigurationManager.Current.Url, ConfigurationManager.Current.ApiKey); if (_directory != null) { textName.Text = _directory.Name; textDescription.Text = _directory.Description; } }
public DirectoryEditForm(SettingsDirectory directory, string applicationName) { InitializeComponent(); this._directory = directory; this._applicationName = applicationName; this.settingsManager = new SettingsAPIClient.SettingsManager(ConfigurationManager.Current.Url, ConfigurationManager.Current.ApiKey); if(_directory != null) { textName.Text = _directory.Name; textDescription.Text = _directory.Description; } }
public async Task CreateApplicationMasterAsync() { settingsManager = new SettingsManager(_url, _masterKey); string applicationName = Util.RandomString(); string description = Util.RandomString(); await settingsManager.CreateApplicationAsync(applicationName, description); currentApplication = await settingsManager.GetApplication(applicationName); Assert.AreEqual(currentApplication.Name, applicationName); Assert.AreEqual(currentApplication.Description, description); currentApplicationName = currentApplication.Name; }
public async Task AuthenticateWrongAPIKey() { settingsManager = new SettingsManager(_url, "123"); try { await settingsManager.OpenDirectoryAsync("SampleApplication", "root"); Assert.Fail("Allowed access using wrong key"); } catch (SettingAccessDeniedException) { } try { //unknown resource await settingsManager.OpenDirectoryAsync(Util.RandomString()); Assert.Fail("Allowed access using wrong key"); } catch (SettingAccessDeniedException) { } }
private async Task GetApplications() { try { if (string.IsNullOrWhiteSpace(ConfigurationManager.Current.ApiKey)) { AskApiKeyForm form = new AskApiKeyForm(ConfigurationManager.Current.ApiKey); form.ShowDialog(); if (string.IsNullOrWhiteSpace(form.ApiKey)) { MessageBox.Show("No API Key. Application will exit."); this.Close(); } } settingsManager = new SettingsAPIClient.SettingsManager(ConfigurationManager.Current.Url, ConfigurationManager.Current.ApiKey); IEnumerable<SettingsApplication> applications = null; try { applications = await settingsManager.GetApplications(); } catch (AggregateException ex) { MessageBox.Show(ex.InnerException.Message); } gridControl1.DataSource = applications.ToList(); } catch (SettingsException ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public ApplicationUserControl(string applicationName) { InitializeComponent(); settingsManager = new SettingsAPIClient.SettingsManager(ConfigurationManager.Current.Url, ConfigurationManager.Current.ApiKey); this.applicationName = applicationName; }
public ApplicationUserControl(string applicationName) { InitializeComponent(); settingsManager = new SettingsAPIClient.SettingsManager(ConfigurationManager.Current.Url, ConfigurationManager.Current.ApiKey); this.applicationName = applicationName; }
public async Task CreateApiKeyAndTestAccess() { await CreateApplicationMasterAsync(); var applicationName = currentApplication.Name; //Get the adminKey for this application. var result = await settingsManager.GetApiKey(applicationName, applicationName); settingsManager = new SettingsManager(_url, result.Key); //Create a directory to set access for. await settingsManager.CreateDirectoryAsync(applicationName, "Dir1", "test"); await settingsManager.CreateDirectoryAsync(applicationName, "Dir2", "test"); ApiKey key = new ApiKey(); //Save a single setting var dir = await settingsManager.OpenDirectoryAsync(applicationName, "Dir1"); await dir.SaveAsync("testKey", true); key.Name = "1000"; key.AdminKey = false; key.Active = true; key.Access = new System.Collections.Generic.List<ApiAccess>(); key.Access.Add(new ApiAccess { Create = false, Delete = false, Write = false, Directory = "Dir1" }); var newKey = await settingsManager.CreateApiKey(applicationName, key); Assert.IsTrue(newKey.Active); Assert.AreEqual(newKey.Name, key.Name); Assert.IsTrue(newKey.Access.SingleOrDefault(a => a.Directory == "Dir1") != null); Assert.IsTrue(newKey.Access.SingleOrDefault(a => a.Directory == "Dir2") == null); ApiAccess access = newKey.Access.Single(); Assert.IsFalse(access.Create); Assert.IsFalse(access.Delete); Assert.IsFalse(access.Write); settingsManager = new SettingsManager(_url, newKey.Key); var testDir = await settingsManager.OpenDirectoryAsync(currentApplicationName, "Dir1"); var testSetting = await testDir.GetBooleanAsync("testKey"); try { await testDir.SaveAsync("testKey", false); } catch (SettingAccessDeniedException) { } try { await testDir.DeleteAsync(0, "testKey"); } catch (SettingAccessDeniedException){} try { await testDir.SaveAsync("testKey2", true); } catch (SettingAccessDeniedException) { } }