コード例 #1
0
ファイル: test_tag_tt2.py プロジェクト: nfcpy/nfcpy
 def test_protect_dynamic_locktlv_lockbits(self, tag):
     commands = [
         (HEX('30 00'), 0.005),
         (HEX('30 04'), 0.005),
         (HEX('a2 03 e110080f'), 0.1),
         (HEX('30 08'), 0.005),
         (HEX('30 0c'), 0.005),
         (HEX('30 10'), 0.005),
         (HEX('30 14'), 0.005),
         (HEX('a2 02 0000ffff'), 0.1),
         (HEX('a2 14 ffff0000'), 0.1),
     ]
     responses = [
         HEX("01020304 05060708 00000000 E1100800"),
         HEX("00000103 a0102300 0300fe00 00000000"),
         HEX("0a"),
         HEX("00000000 00000000 00000000 00000000"),
         HEX("00000000 00000000 00000000 00000000"),
         HEX("00000000 00000000 00000000 00000000"),
         HEX("00000000 00000000 00000000 00000000"),
         HEX("0a"),
         HEX("0a"),
     ]
     tag.clf.exchange.side_effect = responses
     assert tag.ndef is not None
     assert tag.ndef.octets == b''
     assert tag.ndef.is_writeable is True
     assert tag.ndef.is_readable is True
     assert tag.protect() is True
     assert tag.clf.exchange.mock_calls == [mock.call(*_) for _ in commands]
コード例 #2
0
ファイル: test_tag_tt2.py プロジェクト: cashtang/nfcpy
 def test_protect_dynamic_locktlv_lockbits(self, tag):
     commands = [
         (HEX('30 00'), 0.005),
         (HEX('30 04'), 0.005),
         (HEX('a2 03 e110080f'), 0.1),
         (HEX('30 08'), 0.005),
         (HEX('30 0c'), 0.005),
         (HEX('30 10'), 0.005),
         (HEX('30 14'), 0.005),
         (HEX('a2 02 0000ffff'), 0.1),
         (HEX('a2 14 ffff0000'), 0.1),
     ]
     responses = [
         HEX("01020304 05060708 00000000 E1100800"),
         HEX("00000103 a0102300 0300fe00 00000000"),
         HEX("0a"),
         HEX("00000000 00000000 00000000 00000000"),
         HEX("00000000 00000000 00000000 00000000"),
         HEX("00000000 00000000 00000000 00000000"),
         HEX("00000000 00000000 00000000 00000000"),
         HEX("0a"),
         HEX("0a"),
     ]
     tag.clf.exchange.side_effect = responses
     assert tag.ndef is not None
     assert tag.ndef.octets == b''
     assert tag.ndef.is_writeable is True
     assert tag.ndef.is_readable is True
     assert tag.protect() is True
     assert tag.clf.exchange.mock_calls == [call(*_) for _ in commands]
コード例 #3
0
ファイル: test_tag_tt2.py プロジェクト: cashtang/nfcpy
 def test_protect_blank_tag(self, tag):
     commands = [
         (HEX('30 00'), 0.005),
     ]
     responses = [
         HEX("01020304 05060708 00000000 00000000"),
     ]
     tag.clf.exchange.side_effect = responses
     assert tag.protect() is False
     assert tag.clf.exchange.mock_calls == [call(*_) for _ in commands]
コード例 #4
0
ファイル: test_tag_tt2.py プロジェクト: nfcpy/nfcpy
 def test_protect_blank_tag(self, tag):
     commands = [
         (HEX('30 00'), 0.005),
     ]
     responses = [
         HEX("01020304 05060708 00000000 00000000"),
     ]
     tag.clf.exchange.side_effect = responses
     assert tag.protect() is False
     assert tag.clf.exchange.mock_calls == [mock.call(*_) for _ in commands]
コード例 #5
0
 def test_protect_default(self, tag):
     tag.clf.exchange.side_effect = [
         HEX("1200") + self.mmap[:120],  # RALL
         HEX("0F") + self.mmap[120:128],  # READ8(15)
         HEX("10") + self.mmap[128:256],  # RSEG(1)
         HEX("20") + self.mmap[256:384],  # RSEG(2)
         HEX("30") + self.mmap[384:512],  # RSEG(3)
         HEX("0B 0F"),  # WRITE-NE(11)
     ]
     assert tag.protect() is True
     tag.clf.exchange.assert_called_with(HEX("1A 0B 0F 01020304"), 0.1)
コード例 #6
0
ファイル: test_tag_tt1_broadcom.py プロジェクト: nfcpy/nfcpy
 def test_protect_with_defaults(self, tag):
     tag.clf.exchange.side_effect = [
         tag.target.rid_res[:2] + self.mmap[:120],  # RALL
         HEX("0b 0f"),  # WRITE-E
         HEX("70 ff"),  # WRITE-E
         HEX("71 ff"),  # WRITE-E
     ]
     assert tag.protect() is True
     assert tag.clf.exchange.mock_calls == [
         mock.call(HEX("00 00 00 01020304"), 0.1),  # RALL
         mock.call(HEX("1a 0b 0f 01020304"), 0.1),  # WRITE-E
         mock.call(HEX("1a 70 ff 01020304"), 0.1),  # WRITE-E
         mock.call(HEX("1a 71 ff 01020304"), 0.1),  # WRITE-E
     ]
コード例 #7
0
 def test_protect_with_defaults(self, tag):
     tag.clf.exchange.side_effect = [
         tag.target.rid_res[:2] + self.mmap[:120],  # RALL
         HEX("0b 0f"),  # WRITE-E
         HEX("70 ff"),  # WRITE-E
         HEX("71 ff"),  # WRITE-E
     ]
     assert tag.protect() is True
     assert tag.clf.exchange.mock_calls == [
         call(HEX("00 00 00 01020304"), 0.1),  # RALL
         call(HEX("1a 0b 0f 01020304"), 0.1),  # WRITE-E
         call(HEX("1a 70 ff 01020304"), 0.1),  # WRITE-E
         call(HEX("1a 71 ff 01020304"), 0.1),  # WRITE-E
     ]
コード例 #8
0
ファイル: test_tag_tt1_broadcom.py プロジェクト: nfcpy/nfcpy
 def test_protect_with_defaults(self, tag):
     tag.clf.exchange.side_effect = [               # Responses
         tag.target.rid_res[:2] + self.mmap[:120],  # RALL
         HEX("0F") + self.mmap[120:128],        # READ8(15)
         HEX("10") + self.mmap[128:256],        # RSEG(1)
         HEX("20") + self.mmap[256:384],        # RSEG(2)
         HEX("0b 0f"),                          # WRITE-NE(11)
         HEX("70 ff"),                          # WRITE-NE(112)
         HEX("71 ff"),                          # WRITE-NE(113)
         HEX("78 ff"),                          # WRITE-NE(120)
         HEX("79 ff"),                          # WRITE-NE(121)
     ] + 30 * [nfc.clf.TimeoutError]
     assert tag.protect() is True
     assert tag.clf.exchange.mock_calls == [
         mock.call(HEX("00 00 00 01020304"), 0.1),
         mock.call(HEX("02 0f 0000000000000000 01020304"), 0.1),
         mock.call(HEX("10 10 0000000000000000 01020304"), 0.1),
         mock.call(HEX("10 20 0000000000000000 01020304"), 0.1),
         mock.call(HEX("1a 0b 0f 01020304"), 0.1),
         mock.call(HEX("1a 70 ff 01020304"), 0.1),
         mock.call(HEX("1a 71 ff 01020304"), 0.1),
         mock.call(HEX("1a 78 ff 01020304"), 0.1),
         mock.call(HEX("1a 79 ff 01020304"), 0.1),
     ]
コード例 #9
0
 def test_protect_with_defaults(self, tag):
     tag.clf.exchange.side_effect = [               # Responses
         tag.target.rid_res[:2] + self.mmap[:120],  # RALL
         HEX("0F") + self.mmap[120:128],        # READ8(15)
         HEX("10") + self.mmap[128:256],        # RSEG(1)
         HEX("20") + self.mmap[256:384],        # RSEG(2)
         HEX("0b 0f"),                          # WRITE-NE(11)
         HEX("70 ff"),                          # WRITE-NE(112)
         HEX("71 ff"),                          # WRITE-NE(113)
         HEX("78 ff"),                          # WRITE-NE(120)
         HEX("79 ff"),                          # WRITE-NE(121)
     ] + 30 * [nfc.clf.TimeoutError]
     assert tag.protect() is True
     assert tag.clf.exchange.mock_calls == [
         call(HEX("00 00 00 01020304"), 0.1),
         call(HEX("02 0f 0000000000000000 01020304"), 0.1),
         call(HEX("10 10 0000000000000000 01020304"), 0.1),
         call(HEX("10 20 0000000000000000 01020304"), 0.1),
         call(HEX("1a 0b 0f 01020304"), 0.1),
         call(HEX("1a 70 ff 01020304"), 0.1),
         call(HEX("1a 71 ff 01020304"), 0.1),
         call(HEX("1a 78 ff 01020304"), 0.1),
         call(HEX("1a 79 ff 01020304"), 0.1),
     ]
コード例 #10
0
ファイル: test_tag_tag.py プロジェクト: cotton105/NFCRegister
def test_tag_protect(tag):
    assert tag.protect() is None
コード例 #11
0
ファイル: test_tag_tt1_broadcom.py プロジェクト: nfcpy/nfcpy
 def test_protect_with_password(self, tag):
     assert tag.protect("abcdefg") is False
コード例 #12
0
 def test_protect_not_ndef(self, tag):
     tag.clf.exchange.side_effect = [
         HEX("1200") + self.mmap[:8] + b"\0" + self.mmap[9:120],
     ]
     assert tag.protect() is False
コード例 #13
0
 def test_protect_password(self, tag):
     assert tag.protect("abcdefg") is False
コード例 #14
0
ファイル: test_tag_tt2.py プロジェクト: cashtang/nfcpy
 def test_protect_with_password(self, tag):
     assert tag.protect(b'') is False
コード例 #15
0
ファイル: test_tag_tt2.py プロジェクト: nfcpy/nfcpy
 def test_protect_with_password(self, tag):
     assert tag.protect(b'') is False