Esempio n. 1
0
        public static void AddDummyUserIfRequired(Funq.Container container)
        {
            // create a dummy user
            var fac = container.Resolve<IDbConnectionFactory> ();
            using (var db = fac.OpenDbConnection ()) {

                if (db.FirstOrDefault<DBUser> (u => u.Username == "dummy") == null) {

                    var user = new DBUser ();
                    user.Username = "******";
                    user.CreateCryptoFields ("foobar123");
                    user.FirstName = "John Dummy";
                    user.LastName = "Doe";
                    user.AdditionalData  = "Dummy user that is created when in development mode";
                    user.IsActivated = true;
                    user.IsVerified = true;
                    user.Manifest.LastSyncRevision = 0;
                    user.EmailAddress = "*****@*****.**";
                    db.Insert<DBUser> (user);
                    // insert some sample notes
                    var f = container.Resolve<IDbStorageFactory> ();
                    var key = user.GetPlaintextMasterKey ("foobar123");
                    var r = new RequestingUser {
                        Username = "******",
                        EncryptionMasterKey = key.ToHexString ()
                    };
                    using (var storage = f.GetDbStorage (r)) {
                        var sample_notes = new DiskStorage ();
                        sample_notes.SetPath ("../../../sample_notes/");
                        sample_notes.CopyTo (storage);
                    }

                }
            }
        }
Esempio n. 2
0
        public void ReadWriteManifest()
        {
            var data_backend = RainyTestServer.Container.Resolve<IDataBackend> ();
            var requesting_user = new RequestingUser { Username = RainyTestServer.TEST_USER, EncryptionMasterKey = "deadbeefaffedeadbeef0ffe" };

            var server_id = Guid.NewGuid ().ToString ();
            using (var repo = data_backend.GetNoteRepository (requesting_user)) {
                repo.Manifest.LastSyncRevision = 123;
                repo.Manifest.ServerId = server_id;
            }

            // check the manifest got saved
            using (var repo = data_backend.GetNoteRepository (requesting_user)) {
                Assert.AreEqual (123, repo.Manifest.LastSyncRevision);
                Assert.AreEqual (server_id, repo.Manifest.ServerId);
            }
        }