Esempio n. 1
0
  def setUp( self ):
    Test_controller.setUp( self )

    self.notebook = Notebook.create( self.database.next_id( Notebook ), u"my notebook", trash_id = u"foo" )
    self.database.save( self.notebook )

    self.anon_notebook = Notebook.create( self.database.next_id( Notebook ), u"Luminotes" )
    self.database.save( self.anon_notebook )
    self.anon_note = Note.create(
      self.database.next_id( Note ), u"<h3>my note</h3>",
      notebook_id = self.anon_notebook.object_id,
    )
    self.database.save( self.anon_note )

    self.login_note = Note.create(
      self.database.next_id( Note ), u"<h3>login</h3>",
      notebook_id = self.anon_notebook.object_id,
    )
    self.database.save( self.login_note )

    self.blog_notebook = Notebook.create( self.database.next_id( Notebook ), u"Luminotes blog" )
    self.database.save( self.blog_notebook )
    self.blog_note = Note.create(
      self.database.next_id( Note ), u"<h3>my blog entry</h3>",
      notebook_id = self.blog_notebook.object_id,
    )
    self.database.save( self.blog_note )

    self.guide_notebook = Notebook.create( self.database.next_id( Notebook ), u"Luminotes user guide" )
    self.database.save( self.guide_notebook )
    self.guide_note = Note.create(
      self.database.next_id( Note ), u"<h3>it's all self-explanatory</h3>",
      notebook_id = self.guide_notebook.object_id,
    )
    self.database.save( self.guide_note )

    self.privacy_notebook = Notebook.create( self.database.next_id( Notebook ), u"Luminotes privacy policy" )
    self.database.save( self.privacy_notebook )
    self.privacy_note = Note.create(
      self.database.next_id( Note ), u"<h3>yay privacy</h3>",
      notebook_id = self.privacy_notebook.object_id,
    )
    self.database.save( self.privacy_note )

    self.username = u"mulder"
    self.password = u"trustno1"
    self.email_address = u"*****@*****.**"
    self.user = None
    self.session_id = None

    self.user = User.create( self.database.next_id( User ), self.username, self.password, self.email_address )
    self.database.save( self.user )
    self.database.execute( self.user.sql_save_notebook( self.notebook.object_id ) )

    self.anonymous = User.create( self.database.next_id( User ), u"anonymous" )
    self.database.save( self.anonymous )
    self.database.execute( self.anonymous.sql_save_notebook( self.anon_notebook.object_id, read_write = False, owner = False, rank = 0 ) )
    self.database.execute( self.anonymous.sql_save_notebook( self.blog_notebook.object_id, read_write = False, owner = False, rank = 1 ) )
    self.database.execute( self.anonymous.sql_save_notebook( self.guide_notebook.object_id, read_write = False, owner = False, rank = 2 ) )
    self.database.execute( self.anonymous.sql_save_notebook( self.privacy_notebook.object_id, read_write = False, owner = False, rank = 3 ) )
Esempio n. 2
0
  def setUp( self ):
    Test_controller.setUp( self )
    Groups.urllib2 = Stub_urllib2

    self.group_name = u"my group"
    self.group_name2 = u"other group"
    self.username = u"mulder"
    self.password = u"trustno1"
    self.email_address = u"*****@*****.**"
    self.username2 = u"scully"
    self.password2 = u"trustsome1"
    self.email_address2 = u"*****@*****.**"
    self.username3 = u"skinner"
    self.password3 = u"trustne1"
    self.email_address3 = u"*****@*****.**"

    self.group = Group.create( self.database.next_id( Group ), self.group_name )
    self.database.save( self.group, commit = False )

    self.group2 = Group.create( self.database.next_id( Group ), self.group_name )
    self.database.save( self.group2, commit = False )

    self.user = User.create( self.database.next_id( User ), self.username, self.password, self.email_address )
    self.database.save( self.user, commit = False )
    self.database.execute( self.user.sql_save_group( self.group.object_id, admin = False ) )

    self.user2 = User.create( self.database.next_id( User ), self.username2, self.password2, self.email_address2 )
    self.database.save( self.user2, commit = False )
    self.database.execute( self.user2.sql_save_group( self.group.object_id, admin = True ) )

    self.user3 = User.create( self.database.next_id( User ), self.username3, self.password3, self.email_address3 )
    self.database.save( self.user3, commit = False )
    self.database.execute( self.user3.sql_save_group( self.group.object_id, admin = False ) )

    self.database.commit()
Esempio n. 3
0
  def setUp( self ):
    self.database = Database(
      Connection_wrapper( sqlite.connect( ":memory:", detect_types = sqlite.PARSE_DECLTYPES, check_same_thread = False ) ),
      cache = Stub_cache(),
    )
    self.database.execute_script( file( "model/schema.sqlite" ).read(), commit = True )

    self.username = u"mulder"
    self.password = u"trustno1"
    self.email_address = u"*****@*****.**"
    self.user = User.create( self.database.next_id( User ), self.username, self.password, self.email_address )
    self.database.save( self.user, commit = False )

    self.trash = Notebook.create( self.database.next_id( Notebook ), u"trash" )
    self.database.save( self.trash, commit = False )
    self.notebook = Notebook.create( self.database.next_id( Notebook ), u"notebook", self.trash.object_id, user_id = self.user.object_id )
    self.database.save( self.notebook, commit = False )

    note_id = self.database.next_id( Note )
    self.note1 = Note.create( note_id, u"<h3>my title</h3>blah", notebook_id = self.notebook.object_id, startup = True, user_id = self.user.object_id )
    self.database.save( self.note1, commit = False )

    note_id = self.database.next_id( Note )
    self.note2 = Note.create( note_id, u"<h3>other title</h3>whee", notebook_id = self.notebook.object_id, user_id = self.user.object_id )
    self.database.save( self.note2, commit = False )
Esempio n. 4
0
  def create_anonymous_user( self ):
    # create the anonymous user
    anonymous_user_id = self.database.next_id( User )
    self.anonymous = User.create( anonymous_user_id, u"anonymous", None, None )
    self.database.save( self.anonymous, commit = False )

    # give the anonymous user read-only access to the main notebook
    self.database.execute( self.anonymous.sql_save_notebook( self.main_notebook.object_id, read_write = False, owner = False ), commit = False )
Esempio n. 5
0
  def setUp( self ):
    self.object_id = u"17"
    self.username = u"bob"
    self.password = u"foobar"
    self.email_address = u"*****@*****.**"
    self.delta = timedelta( seconds = 1 )

    self.user = User.create( self.object_id, self.username, self.password, self.email_address )
Esempio n. 6
0
    def setUp(self):
        self.object_id = u"17"
        self.username = u"bob"
        self.password = u"foobar"
        self.email_address = u"*****@*****.**"
        self.delta = timedelta(seconds=1)

        self.user = User.create(self.object_id, self.username, self.password,
                                self.email_address)
Esempio n. 7
0
 def createUserFromRegistrationForm(self, email, password, firstName,
                                    lastName):
     salt = str(os.urandom(20))
     currentSession = str(os.urandom(20))
     user = User.create(email=email,
                        firstName=firstName,
                        lastName=lastName,
                        password=self.hashPassword(password, salt),
                        salt=salt,
                        currentSession=currentSession)
     return user
Esempio n. 8
0
    def create_anonymous_user(self):
        # create the anonymous user
        anonymous_user_id = self.database.next_id(User)
        self.anonymous = User.create(anonymous_user_id, u"anonymous", None,
                                     None)
        self.database.save(self.anonymous, commit=False)

        # give the anonymous user read-only access to the main notebook
        self.database.execute(self.anonymous.sql_save_notebook(
            self.main_notebook.object_id, read_write=False, owner=False),
                              commit=False)
Esempio n. 9
0
    def sign_up(self, info):
        """create new account"""
        if 'email' not in info or 'password' not in info or len(
                info['email']) * len(info['password']) == 0:
            return {"status": False, "message": "Invalid Arguments"}

        newbody = User.create(**info)
        if newbody is None:
            return {
                "status": False,
                "message": "Mail address is already in use."
            }

        result = self.authservice.login(info['email'], info['password'])
        return {"status": True, "token": result["token"]}
Esempio n. 10
0
    def setUp(self):
        self.database = Database(
            Connection_wrapper(
                sqlite.connect(":memory:",
                               detect_types=sqlite.PARSE_DECLTYPES,
                               check_same_thread=False)),
            cache=Stub_cache(),
        )
        self.database.execute_script(file("model/schema.sqlite").read(),
                                     commit=True)

        self.username = u"mulder"
        self.password = u"trustno1"
        self.email_address = u"*****@*****.**"
        self.user = User.create(self.database.next_id(User), self.username,
                                self.password, self.email_address)
        self.database.save(self.user, commit=False)

        self.trash = Notebook.create(self.database.next_id(Notebook), u"trash")
        self.database.save(self.trash, commit=False)
        self.notebook = Notebook.create(self.database.next_id(Notebook),
                                        u"notebook",
                                        self.trash.object_id,
                                        user_id=self.user.object_id)
        self.database.save(self.notebook, commit=False)

        note_id = self.database.next_id(Note)
        self.note1 = Note.create(note_id,
                                 u"<h3>my title</h3>blah",
                                 notebook_id=self.notebook.object_id,
                                 startup=True,
                                 user_id=self.user.object_id)
        self.database.save(self.note1, commit=False)

        note_id = self.database.next_id(Note)
        self.note2 = Note.create(note_id,
                                 u"<h3>other title</h3>whee",
                                 notebook_id=self.notebook.object_id,
                                 user_id=self.user.object_id)
        self.database.save(self.note2, commit=False)
Esempio n. 11
0
    def setUp(self):
        Test_controller.setUp(self)

        self.notebook = Notebook.create(self.database.next_id(Notebook),
                                        u"my notebook",
                                        trash_id=u"foo")
        self.database.save(self.notebook)

        self.anon_notebook = Notebook.create(self.database.next_id(Notebook),
                                             u"Luminotes",
                                             trash_id=u"bar")
        self.database.save(self.anon_notebook)
        self.anon_note = Note.create(
            self.database.next_id(Note),
            u"<h3>my note</h3>",
            notebook_id=self.anon_notebook.object_id,
        )
        self.database.save(self.anon_note)

        self.login_note = Note.create(
            self.database.next_id(Note),
            u"<h3>login</h3>",
            notebook_id=self.anon_notebook.object_id,
        )
        self.database.save(self.login_note)

        self.username = u"mulder"
        self.password = u"trustno1"
        self.email_address = u"*****@*****.**"
        self.user = None
        self.session_id = None

        self.user = User.create(self.database.next_id(User), self.username,
                                self.password, self.email_address)
        self.database.save(self.user)
        self.database.execute(
            self.user.sql_save_notebook(self.notebook.object_id))

        self.anonymous = User.create(self.database.next_id(User), u"anonymous")
        self.database.save(self.anonymous)
        self.database.execute(
            self.anonymous.sql_save_notebook(self.anon_notebook.object_id))

        self.blog_user = User.create(self.database.next_id(User), u"witten",
                                     self.password, self.email_address)
        self.database.save(self.blog_user)

        tag_id = self.database.next_id(Tag)
        self.forum_tag = Tag.create(
            tag_id,
            notebook_id=
            None,  # this tag is not in the namespace of a single notebook
            user_id=self.anonymous.object_id,
            name=u"forum",
            description=u"a discussion forum")
        self.database.save(self.forum_tag)

        self.general_thread = Notebook.create(
            self.database.next_id(Notebook), u"Welcome to the general forum!")
        self.database.save(self.general_thread)
        self.database.execute(
            self.anonymous.sql_save_notebook(
                self.general_thread.object_id,
                read_write=Notebook.READ_WRITE_FOR_OWN_NOTES), )
        self.database.execute(
            self.anonymous.sql_save_notebook_tag(self.general_thread.object_id,
                                                 self.forum_tag.object_id,
                                                 value=u"general"), )

        self.support_thread = Notebook.create(
            self.database.next_id(Notebook), u"Welcome to the support forum!")
        self.database.save(self.support_thread)
        self.database.execute(
            self.anonymous.sql_save_notebook(
                self.support_thread.object_id,
                read_write=Notebook.READ_WRITE_FOR_OWN_NOTES), )
        self.database.execute(
            self.anonymous.sql_save_notebook_tag(self.support_thread.object_id,
                                                 self.forum_tag.object_id,
                                                 value=u"support"), )

        self.blog_thread = Notebook.create(self.database.next_id(Notebook),
                                           u"Welcome to the blog!")
        self.database.save(self.blog_thread)
        self.database.execute(
            self.anonymous.sql_save_notebook(
                self.blog_thread.object_id,
                read_write=Notebook.READ_WRITE_FOR_OWN_NOTES), )
        self.database.execute(
            self.blog_user.sql_save_notebook(self.blog_thread.object_id,
                                             read_write=Notebook.READ_WRITE), )
        self.database.execute(
            self.anonymous.sql_save_notebook_tag(self.blog_thread.object_id,
                                                 self.forum_tag.object_id,
                                                 value=u"forum"), )
Esempio n. 12
0
    def setUp(self):
        Test_controller.setUp(self)

        self.notebook = Notebook.create(self.database.next_id(Notebook),
                                        u"my notebook",
                                        trash_id=u"foo")
        self.database.save(self.notebook)

        self.anon_notebook = Notebook.create(self.database.next_id(Notebook),
                                             u"Luminotes")
        self.database.save(self.anon_notebook)
        self.anon_note = Note.create(
            self.database.next_id(Note),
            u"<h3>my note</h3>",
            notebook_id=self.anon_notebook.object_id,
        )
        self.database.save(self.anon_note)

        self.login_note = Note.create(
            self.database.next_id(Note),
            u"<h3>login</h3>",
            notebook_id=self.anon_notebook.object_id,
        )
        self.database.save(self.login_note)

        self.blog_notebook = Notebook.create(self.database.next_id(Notebook),
                                             u"Luminotes blog")
        self.database.save(self.blog_notebook)
        self.blog_note = Note.create(
            self.database.next_id(Note),
            u"<h3>my blog entry</h3>",
            notebook_id=self.blog_notebook.object_id,
        )
        self.database.save(self.blog_note)

        self.guide_notebook = Notebook.create(self.database.next_id(Notebook),
                                              u"Luminotes user guide")
        self.database.save(self.guide_notebook)
        self.guide_note = Note.create(
            self.database.next_id(Note),
            u"<h3>it's all self-explanatory</h3>",
            notebook_id=self.guide_notebook.object_id,
        )
        self.database.save(self.guide_note)

        self.privacy_notebook = Notebook.create(
            self.database.next_id(Notebook), u"Luminotes privacy policy")
        self.database.save(self.privacy_notebook)
        self.privacy_note = Note.create(
            self.database.next_id(Note),
            u"<h3>yay privacy</h3>",
            notebook_id=self.privacy_notebook.object_id,
        )
        self.database.save(self.privacy_note)

        self.username = u"mulder"
        self.password = u"trustno1"
        self.email_address = u"*****@*****.**"
        self.user = None
        self.session_id = None

        self.user = User.create(self.database.next_id(User), self.username,
                                self.password, self.email_address)
        self.database.save(self.user)
        self.database.execute(
            self.user.sql_save_notebook(self.notebook.object_id))

        self.anonymous = User.create(self.database.next_id(User), u"anonymous")
        self.database.save(self.anonymous)
        self.database.execute(
            self.anonymous.sql_save_notebook(self.anon_notebook.object_id,
                                             read_write=False,
                                             owner=False,
                                             rank=0))
        self.database.execute(
            self.anonymous.sql_save_notebook(self.blog_notebook.object_id,
                                             read_write=False,
                                             owner=False,
                                             rank=1))
        self.database.execute(
            self.anonymous.sql_save_notebook(self.guide_notebook.object_id,
                                             read_write=False,
                                             owner=False,
                                             rank=2))
        self.database.execute(
            self.anonymous.sql_save_notebook(self.privacy_notebook.object_id,
                                             read_write=False,
                                             owner=False,
                                             rank=3))
Esempio n. 13
0
  def setUp( self ):
    Test_controller.setUp( self )

    self.notebook = Notebook.create( self.database.next_id( Notebook ), u"my notebook", trash_id = u"foo" )
    self.database.save( self.notebook )

    self.anon_notebook = Notebook.create( self.database.next_id( Notebook ), u"Luminotes", trash_id = u"bar" )
    self.database.save( self.anon_notebook )
    self.anon_note = Note.create(
      self.database.next_id( Note ), u"<h3>my note</h3>",
      notebook_id = self.anon_notebook.object_id,
    )
    self.database.save( self.anon_note )

    self.login_note = Note.create(
      self.database.next_id( Note ), u"<h3>login</h3>",
      notebook_id = self.anon_notebook.object_id,
    )
    self.database.save( self.login_note )

    self.username = u"mulder"
    self.password = u"trustno1"
    self.email_address = u"*****@*****.**"
    self.user = None
    self.session_id = None

    self.user = User.create( self.database.next_id( User ), self.username, self.password, self.email_address )
    self.database.save( self.user )
    self.database.execute( self.user.sql_save_notebook( self.notebook.object_id ) )

    self.anonymous = User.create( self.database.next_id( User ), u"anonymous" )
    self.database.save( self.anonymous )
    self.database.execute( self.anonymous.sql_save_notebook( self.anon_notebook.object_id ) )

    self.blog_user = User.create( self.database.next_id( User ), u"witten", self.password, self.email_address )
    self.database.save( self.blog_user )

    tag_id = self.database.next_id( Tag )
    self.forum_tag = Tag.create(
      tag_id,
      notebook_id = None, # this tag is not in the namespace of a single notebook
      user_id = self.anonymous.object_id,
      name = u"forum",
      description = u"a discussion forum"
    )
    self.database.save( self.forum_tag )

    self.general_thread = Notebook.create( self.database.next_id( Notebook ), u"Welcome to the general forum!" )
    self.database.save( self.general_thread )
    self.database.execute(
      self.anonymous.sql_save_notebook( self.general_thread.object_id, read_write = Notebook.READ_WRITE_FOR_OWN_NOTES ),
    )
    self.database.execute(
      self.anonymous.sql_save_notebook_tag( self.general_thread.object_id, self.forum_tag.object_id, value = u"general" ),
    )

    self.support_thread = Notebook.create( self.database.next_id( Notebook ), u"Welcome to the support forum!" )
    self.database.save( self.support_thread )
    self.database.execute(
      self.anonymous.sql_save_notebook( self.support_thread.object_id, read_write = Notebook.READ_WRITE_FOR_OWN_NOTES ),
    )
    self.database.execute(
      self.anonymous.sql_save_notebook_tag( self.support_thread.object_id, self.forum_tag.object_id, value = u"support" ),
    )

    self.blog_thread = Notebook.create( self.database.next_id( Notebook ), u"Welcome to the blog!" )
    self.database.save( self.blog_thread )
    self.database.execute(
      self.anonymous.sql_save_notebook( self.blog_thread.object_id, read_write = Notebook.READ_WRITE_FOR_OWN_NOTES ),
    )
    self.database.execute(
      self.blog_user.sql_save_notebook( self.blog_thread.object_id, read_write = Notebook.READ_WRITE ),
    )
    self.database.execute(
      self.anonymous.sql_save_notebook_tag( self.blog_thread.object_id, self.forum_tag.object_id, value = u"forum" ),
    )