Beispiel #1
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);
        }
Beispiel #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);
        }
Beispiel #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");
        }
Beispiel #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 :-(");
        }
Beispiel #5
0
        public IActionResult UploadFile(IFormFile uploadFile)
        {
            LoadDb loadDb = new LoadDb(uploadFile, appDbContext);

            ViewData["Message"] = loadDb.LoadXmlToBase();
            return(View("Index"));
        }
Beispiel #6
0
        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);
        }