public void LoadFromRemote1And1WrongCredentials() { var ioc = RemoteIoc1and1WrongCredentials; //note: this property is defined in "TestLoadDbCredentials.cs" which is deliberately excluded from Git because the credentials are not public! IKp2aApp app = new TestKp2aApp(); app.CreateNewDatabase(); bool loadSuccesful = false; bool gotError = false; LoadDb task = new LoadDb(app, ioc, null, CreateKey("test"), null, new ActionOnFinish((success, message) => { if (!success) { Android.Util.Log.Debug("KP2ATest", "error loading db: " + message); gotError = true; } loadSuccesful = success; }) ); ProgressTask pt = new ProgressTask(app, Application.Context, task); Android.Util.Log.Debug("KP2ATest", "Running ProgressTask"); pt.Run(); pt.JoinWorkerThread(); Android.Util.Log.Debug("KP2ATest", "PT.run finished"); Assert.IsFalse(loadSuccesful); Assert.IsTrue(gotError); }
private IKp2aApp PerformLoad(string filenameWithoutDir, string password, string keyfile) { Android.Util.Log.Debug("KP2ATest", "Starting for " + filenameWithoutDir + " with " + password + "/" + keyfile); IKp2aApp app = new TestKp2aApp(); app.CreateNewDatabase(); bool loadSuccesful = false; var key = CreateKey(password, keyfile); string loadErrorMessage = ""; LoadDb task = new LoadDb(app, new IOConnectionInfo { Path = TestDbDirectory + filenameWithoutDir }, null, key, keyfile, new ActionOnFinish((success, message) => { loadErrorMessage = message; if (!success) { Android.Util.Log.Debug("KP2ATest", "error loading db: " + message); } loadSuccesful = success; }) ); ProgressTask pt = new ProgressTask(app, Application.Context, task); Android.Util.Log.Debug("KP2ATest", "Running ProgressTask"); pt.Run(); pt.JoinWorkerThread(); Android.Util.Log.Debug("KP2ATest", "PT.run finished"); Assert.IsTrue(loadSuccesful, "didn't succesfully load database :-( " + loadErrorMessage); return(app); }
public void LoadWithAcceptedCertificateTrustFailure() { var ioc = RemoteCertFailureIoc; //note: this property is defined in "TestLoadDbCredentials.cs" which is deliberately excluded from Git because the credentials are not public! var app = new TestKp2aApp(); app.ServerCertificateErrorResponse = true; app.CreateNewDatabase(); bool loadSuccesful = false; LoadDb task = new LoadDb(app, ioc, null, CreateKey("test"), null, new ActionOnFinish((success, message) => { if (!success) { Android.Util.Log.Debug("KP2ATest", "error loading db: " + message); } loadSuccesful = success; }) ); ProgressTask pt = new ProgressTask(app, Application.Context, task); Android.Util.Log.Debug("KP2ATest", "Running ProgressTask"); pt.Run(); pt.JoinWorkerThread(); Android.Util.Log.Debug("KP2ATest", "PT.run finished"); Assert.IsTrue(loadSuccesful, "database should be loaded because invalid certificates are accepted"); }
public void LoadFromRemoteWithDomain() { //warning, looks like credentials are no longer valid var ioc = RemoteDomainIoc; //note: this property is defined in "TestLoadDbCredentials.cs" which is deliberately excluded from Git because the credentials are not public! var app = new TestKp2aApp(); app.ServerCertificateErrorResponse = true; //accept invalid cert app.CreateNewDatabase(); bool loadSuccesful = false; LoadDb task = new LoadDb(app, ioc, null, CreateKey("a"), null, new ActionOnFinish((success, message) => { if (!success) { Android.Util.Log.Debug("KP2ATest", "error loading db: " + message); } loadSuccesful = success; }) ); ProgressTask pt = new ProgressTask(app, Application.Context, task); Android.Util.Log.Debug("KP2ATest", "Running ProgressTask"); pt.Run(); pt.JoinWorkerThread(); Android.Util.Log.Debug("KP2ATest", "PT.run finished"); Assert.IsTrue(loadSuccesful, "didn't succesfully load database :-("); }
protected TestKp2aApp SetupAppWithDatabase(string filename) { TestKp2aApp app = CreateTestKp2aApp(); IOConnectionInfo ioc = new IOConnectionInfo { Path = filename }; Database db = app.CreateNewDatabase(); if (filename.EndsWith(".kdb")) { db.DatabaseFormat = new KdbDatabaseFormat(app); } db.KpDatabase = new PwDatabase(); CompositeKey compositeKey = new CompositeKey(); compositeKey.AddUserKey(new KcpPassword(DefaultPassword)); if (!String.IsNullOrEmpty(DefaultKeyfile)) { compositeKey.AddUserKey(new KcpKeyFile(DefaultKeyfile)); } db.KpDatabase.New(ioc, compositeKey); db.KpDatabase.KeyEncryptionRounds = 3; db.KpDatabase.Name = "Keepass2Android Testing Password Database"; // Set Database state db.Root = db.KpDatabase.RootGroup; db.Loaded = true; db.SearchHelper = new SearchDbHelper(app); // Add a couple default groups db.KpDatabase.RootGroup.AddGroup(new PwGroup(true, true, "Internet", PwIcon.Key), true); mailGroup = new PwGroup(true, true, "eMail", PwIcon.UserCommunication); db.KpDatabase.RootGroup.AddGroup(mailGroup, true); mailGroup.AddGroup(new PwGroup(true, true, "business", PwIcon.BlackBerry), true); mailEntry = new PwEntry(true, true); mailEntry.Strings.Set(PwDefs.UserNameField, new ProtectedString( true, "*****@*****.**")); mailEntry.Strings.Set(PwDefs.TitleField, new ProtectedString( true, "[email protected] Entry")); mailGroup.AddEntry(mailEntry, true); db.KpDatabase.RootGroup.AddGroup(new PwGroup(true, true, "eMail2", PwIcon.UserCommunication), true); return(app); }
public void LoadAndSaveFromRemote1And1Ftp() { var ioc = RemoteIoc1and1Ftp; //note: this property is defined in "TestLoadDbCredentials.cs" which is deliberately excluded from Git because the credentials are not public! var app = new TestKp2aApp(); app.CreateNewDatabase(); bool loadSuccesful = false; LoadDb task = new LoadDb(app, ioc, null, CreateKey("test"), null, new ActionOnFinish((success, message) => { if (!success) Android.Util.Log.Debug("KP2ATest", "error loading db: " + message); loadSuccesful = success; }) ); ProgressTask pt = new ProgressTask(app, Application.Context, task); Android.Util.Log.Debug("KP2ATest", "Running ProgressTask"); pt.Run(); pt.JoinWorkerThread(); Android.Util.Log.Debug("KP2ATest", "PT.run finished"); Assert.IsTrue(loadSuccesful, "didn't succesfully load database :-("); Assert.IsTrue(TrySaveDatabase(app), "didn't successfully save database."); }
private IKp2aApp PerformLoad(string filenameWithoutDir, string password, string keyfile) { Android.Util.Log.Debug("KP2ATest", "Starting for " + filenameWithoutDir + " with " + password + "/" + keyfile); IKp2aApp app = new TestKp2aApp(); app.CreateNewDatabase(); bool loadSuccesful = false; var key = CreateKey(password, keyfile); string loadErrorMessage = ""; LoadDb task = new LoadDb(app, new IOConnectionInfo {Path = TestDbDirectory + filenameWithoutDir}, null, key, keyfile, new ActionOnFinish((success, message) => { loadErrorMessage = message; if (!success) Android.Util.Log.Debug("KP2ATest", "error loading db: " + message); loadSuccesful = success; }) ); ProgressTask pt = new ProgressTask(app, Application.Context, task); Android.Util.Log.Debug("KP2ATest", "Running ProgressTask"); pt.Run(); pt.JoinWorkerThread(); Android.Util.Log.Debug("KP2ATest", "PT.run finished"); Assert.IsTrue(loadSuccesful, "didn't succesfully load database :-( " + loadErrorMessage); return app; }
public void LoadWithAcceptedCertificateTrustFailure() { var ioc = RemoteCertFailureIoc; //note: this property is defined in "TestLoadDbCredentials.cs" which is deliberately excluded from Git because the credentials are not public! var app = new TestKp2aApp(); app.ServerCertificateErrorResponse = true; app.CreateNewDatabase(); bool loadSuccesful = false; LoadDb task = new LoadDb(app, ioc, null, CreateKey("test"), null, new ActionOnFinish((success, message) => { if (!success) Android.Util.Log.Debug("KP2ATest", "error loading db: " + message); loadSuccesful = success; }) ); ProgressTask pt = new ProgressTask(app, Application.Context, task); Android.Util.Log.Debug("KP2ATest", "Running ProgressTask"); pt.Run(); pt.JoinWorkerThread(); Android.Util.Log.Debug("KP2ATest", "PT.run finished"); Assert.IsTrue(loadSuccesful, "database should be loaded because invalid certificates are accepted"); }
public void LoadFromRemoteWithDomain() { //warning, looks like credentials are no longer valid var ioc = RemoteDomainIoc; //note: this property is defined in "TestLoadDbCredentials.cs" which is deliberately excluded from Git because the credentials are not public! var app = new TestKp2aApp(); app.ServerCertificateErrorResponse = true; //accept invalid cert app.CreateNewDatabase(); bool loadSuccesful = false; LoadDb task = new LoadDb(app, ioc, null, CreateKey("a"), null, new ActionOnFinish((success, message) => { if (!success) Android.Util.Log.Debug("KP2ATest", "error loading db: " + message); loadSuccesful = success; }) ); ProgressTask pt = new ProgressTask(app, Application.Context, task); Android.Util.Log.Debug("KP2ATest", "Running ProgressTask"); pt.Run(); pt.JoinWorkerThread(); Android.Util.Log.Debug("KP2ATest", "PT.run finished"); Assert.IsTrue(loadSuccesful, "didn't succesfully load database :-("); }