예제 #1
0
        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.");
        }
예제 #2
0
        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;
        }
예제 #3
0
        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");
        }
예제 #4
0
        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 :-(");
        }
예제 #5
0
        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);
        }
예제 #6
0
파일: TestBase.cs 프로젝트: pythe/wristpass
        protected TestKp2aApp LoadDatabase(string filename, string password, string keyfile)
        {
            var app = CreateTestKp2aApp();
            app.CreateNewDatabase();
            bool loadSuccesful = false;
            LoadDb task = new LoadDb(app, new IOConnectionInfo() { Path = filename }, null, CreateKey(password, keyfile), keyfile, new ActionOnFinish((success, message) =>
                {
                    if (!success)
                        Kp2aLog.Log(message);
                    loadSuccesful = success;

                })
                );
            ProgressTask pt = new ProgressTask(app, Application.Context, task);
            pt.Run();
            pt.JoinWorkerThread();
            Assert.IsTrue(loadSuccesful);
            return app;
        }