コード例 #1
0
    def setUpSafe(self):
        super().setUpSafe()

        self.post = Post()
        self.post.server = self.server
        self.post.path = '/post1'
        self.post.data = {
            'body': 'How are you?',
        }
        self.post.save()
        UserPostRelation.create(source=self.abraham,
                                type='wrote',
                                target=self.post)

        event = Event()
        event.server = 'aaa'
        event.authors = ['bernard@aaa']
        event.parent = 'aaa/post1'
        event.path = '/post1#c1'
        event.data = {'body': 'Good!'}
        event.signatures = {
            'bernard@aaa': sign_post(event, self.bernard_keypair).hex(),
        }
        event.save()
        process_event(event)
コード例 #2
0
ファイル: test_signing.py プロジェクト: maaaks/andreas
 def test_sign(self):
     self.assertEqual(
         sign_post(self.event,
                   self.abraham_keypair,
                   data={
                       'foo': 'bar',
                       'bar': 'baz'
                   }), self.expected)
コード例 #3
0
ファイル: test_process_event.py プロジェクト: maaaks/andreas
def sign_post_incorrectly(obj: Union[Post, Event], keypair: KeyPair,
                          **kwargs) -> bytes:
    """
    Generates incorrect signature for the object.
    It's like normal :func:`sign_post()`, but incorrect.
    """
    hex = sign_post(obj, keypair, **kwargs).hex().replace('a', 'b')
    return bytes.fromhex(hex)
コード例 #4
0
ファイル: test_process_event.py プロジェクト: maaaks/andreas
    def setUpSafe(self):
        super().setUpSafe()

        self.event = Event()
        self.event.server = 'aaa'
        self.event.authors = ['abraham@aaa']
        self.event.path = '/post1'
        self.event.diff = {
            'body': 'Some text here.',
        }
        self.event.signatures = {
            'abraham@aaa': sign_post(self.event, self.get_abraham2()).hex(),
        }
        self.event.save()
コード例 #5
0
ファイル: test_process_event.py プロジェクト: maaaks/andreas
    def setUpSafe(self):
        super().setUpSafe()

        self.event = Event()
        self.event.server = 'aaa'
        self.event.authors = ['abraham@aaa']
        self.event.path = '/post1'
        self.event.diff = {
            'body': 'Hello, World!',
            'tags': ['Aaa', 'Bbb', 'Ccc'],
        }
        self.event.signatures = {
            'abraham@aaa': sign_post(self.event, self.abraham_keypair).hex(),
        }
        self.event.save()
        process_event(self.event)
コード例 #6
0
ファイル: test_process_event.py プロジェクト: maaaks/andreas
    def setUpSafe(self):
        super().setUpSafe()

        self.event = Event()
        self.event.server = 'aaa'
        self.event.authors = ['abraham@aaa']
        self.event.path = '/post1'
        self.event.diff = {
            'body': 'This event should be rejected.',
        }
        self.event.signatures = {
            'abraham@aaa':
            sign_post_incorrectly(self.event, self.abraham_keypair).hex(),
            'bernard@aaa':
            sign_post(self.event, self.bernard_keypair).hex(),
        }
        self.event.save()
コード例 #7
0
ファイル: test_process_event.py プロジェクト: maaaks/andreas
    def setUpSafe(self):
        super().setUpSafe()

        self.post = Post()
        self.post.server = self.server
        self.post.authors = [self.abraham]
        self.post.path = '/post1'
        self.post.data = {
            'title': 'Hello',
            'subtitle': 'A hello world post',
            'body': 'Hello, World!',
        }
        self.post.save()

        event = Event()
        event.server = 'aaa'
        event.authors = ['abraham@aaa']
        event.path = '/post1'
        event.diff = {
            'title': 'Hello (updated)',
            'subtitle': None,
            'tags': ['Aaa', 'Bbb', 'Ccc'],
        }
        event.signatures = {
            'abraham@aaa':
            sign_post(event,
                      self.abraham_keypair,
                      data={
                          'title': 'Hello (updated)',
                          'body': 'Hello, World!',
                          'tags': ['Aaa', 'Bbb', 'Ccc'],
                      }).hex(),
        }
        event.save()
        process_event(event)

        self.post.reload()
コード例 #8
0
ファイル: test_signing.py プロジェクト: maaaks/andreas
 def test_sign(self):
     self.assertEqual(sign_post(self.event, self.abraham_keypair),
                      self.expected)