-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathauthentication_test.py
47 lines (32 loc) · 1.05 KB
/
authentication_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import pytest
from authentication import StreamReceiver, StreamSender
import filecmp
import subprocess
@pytest.fixture
def fileset1():
file = './data/video1.mp4'
hash0 = '5b96aece304a1422224f9a41b228416028f9ba26b0d1058f400200f06a589949'
return file, hash0
@pytest.fixture
def fileset2():
file = './data/video2.mp4'
hash0 = '03c08f4ee0b576fe319338139c045c89c3e8e9409633bea29442e21425006ea8'
return file, hash0
def helper(Sender, f, h0):
fcopy = f + "copy.mp4"
fstream = f + "stream.bin"
sender = Sender(path=f, buffersize=1024)
sender.write_file(path=fstream)
computed_h0 = sender.get_first_hash()
assert h0 == computed_h0
receiver = StreamReceiver(path=fstream, h=computed_h0, buffersize=1024)
receiver.write_file(path=fcopy)
assert filecmp.cmp(fcopy, f)
subprocess.run(["rm", fcopy])
subprocess.run(["rm", fstream])
def test_authentication1(fileset1):
f, h0 = fileset1
helper(StreamSender, f, h0)
def test_authentication2(fileset2):
f, h0 = fileset2
helper(StreamSender, f, h0)