コード例 #1
0
ファイル: tests.py プロジェクト: ClemsonSoCUnix/django-sshkey
 def test_without_name_with_comment(self):
   key = UserKey(
     user=self.user1,
     key=open(self.key1_path + '.pub').read(),
   )
   key.full_clean()
   key.save()
   self.assertEqual(key.name, 'comment')
コード例 #2
0
ファイル: tests.py プロジェクト: rantecki/django-sshkey
 def test_without_name_with_comment(self):
     key = UserKey(
         user=self.user1,
         key=open(self.key1_path + '.pub').read(),
     )
     key.full_clean()
     key.save()
     self.assertEqual(key.name, 'comment')
コード例 #3
0
ファイル: tests.py プロジェクト: carriercomm/django-sshkey
 def test_import_without_comment(self):
   key = UserKey(
     user = self.user1,
     name = 'name',
     key = open(self.key2_rfc4716_path).read(),
   )
   key.full_clean()
   key.save()
   self.assertEqual(key.key.split()[:2], open(self.key2_path+'.pub').read().split()[:2])
コード例 #4
0
ファイル: tests.py プロジェクト: carriercomm/django-sshkey
 def test_import(self):
   key = UserKey(
     user = self.user1,
     name = 'name',
     key = open(self.key1_pem_path).read(),
   )
   key.full_clean()
   key.save()
   self.assertEqual(key.key.split()[:2], open(self.key1_path+'.pub').read().split()[:2])
コード例 #5
0
ファイル: tests.py プロジェクト: rantecki/django-sshkey
 def test_import_without_comment(self):
     key = UserKey(
         user=self.user1,
         name='name',
         key=open(self.key2_rfc4716_path).read(),
     )
     key.full_clean()
     key.save()
     self.assertEqual(key.key.split()[:2],
                      open(self.key2_path + '.pub').read().split()[:2])
コード例 #6
0
ファイル: tests.py プロジェクト: rantecki/django-sshkey
 def test_fingerprint(self):
     fingerprint = ssh_fingerprint(self.key1_path + '.pub')
     key = UserKey(
         user=self.user1,
         name='name',
         key=open(self.key1_path + '.pub').read(),
     )
     key.full_clean()
     key.save()
     self.assertEqual(key.fingerprint, fingerprint)
コード例 #7
0
ファイル: tests.py プロジェクト: rantecki/django-sshkey
 def test_import(self):
     key = UserKey(
         user=self.user1,
         name='name',
         key=open(self.key1_pem_path).read(),
     )
     key.full_clean()
     key.save()
     self.assertEqual(key.key.split()[:2],
                      open(self.key1_path + '.pub').read().split()[:2])
コード例 #8
0
ファイル: tests.py プロジェクト: ClemsonSoCUnix/django-sshkey
 def test_fingerprint_md5(self):
   settings.SSHKEY_DEFAULT_HASH = 'md5'
   key = UserKey(
     user=self.user1,
     name='name',
     key=open(self.key1_path + '.pub').read(),
   )
   key.full_clean()
   key.save()
   self.assertTrue(key.fingerprint.startswith('MD5:'))
コード例 #9
0
ファイル: tests.py プロジェクト: carriercomm/django-sshkey
 def test_fingerprint(self):
   fingerprint = ssh_fingerprint(self.key1_path+'.pub')
   key = UserKey(
     user = self.user1,
     name = 'name',
     key = open(self.key1_path+'.pub').read(),
   )
   key.full_clean()
   key.save()
   self.assertEqual(key.fingerprint, fingerprint)
コード例 #10
0
ファイル: tests.py プロジェクト: ClemsonSoCUnix/django-sshkey
 def test_fingerprint_legacy(self):
   settings.SSHKEY_DEFAULT_HASH = 'legacy'
   fingerprint = ssh_fingerprint(self.key1_path + '.pub', hash='legacy')
   key = UserKey(
     user=self.user1,
     name='name',
     key=open(self.key1_path + '.pub').read(),
   )
   key.full_clean()
   key.save()
   self.assertEqual(key.fingerprint, fingerprint)
コード例 #11
0
ファイル: tests.py プロジェクト: rantecki/django-sshkey
 def test_touch(self):
     import datetime
     key = UserKey(
         user=self.user1,
         name='name',
         key=open(self.key1_path + '.pub').read(),
     )
     key.full_clean()
     key.save()
     self.assertIsNone(key.last_used)
     key.touch()
     key.save()
     self.assertIsInstance(key.last_used, datetime.datetime)
     key.touch()
コード例 #12
0
ファイル: tests.py プロジェクト: ClemsonSoCUnix/django-sshkey
 def test_touch(self):
   import datetime
   key = UserKey(
     user=self.user1,
     name='name',
     key=open(self.key1_path + '.pub').read(),
   )
   key.full_clean()
   key.save()
   self.assertIsNone(key.last_used)
   key.touch()
   key.save()
   self.assertIsInstance(key.last_used, datetime.datetime)
   key.touch()
コード例 #13
0
ファイル: tests.py プロジェクト: carriercomm/django-sshkey
 def test_export(self):
   key = UserKey(
     user = self.user1,
     name = 'name',
     key = open(self.key1_path+'.pub').read(),
   )
   key.full_clean()
   key.save()
   export_path = os.path.join(self.key_dir, 'export')
   import_path = os.path.join(self.key_dir, 'import')
   with open(export_path, 'w') as f:
     f.write(key.export('PEM'))
   ssh_key_import(export_path, import_path, 'PEM')
   self.assertEqual(open(import_path).read().split()[:2], open(self.key1_path+'.pub').read().split()[:2])
コード例 #14
0
ファイル: tests.py プロジェクト: rantecki/django-sshkey
 def test_same_key_different_user(self):
     key1 = UserKey(
         user=self.user1,
         name='name1',
         key=open(self.key1_path + '.pub').read(),
     )
     key1.full_clean()
     key1.save()
     key2 = UserKey(
         user=self.user2,
         name='name2',
         key=open(self.key1_path + '.pub').read(),
     )
     self.assertRaises(ValidationError, key2.full_clean)
コード例 #15
0
ファイル: tests.py プロジェクト: ClemsonSoCUnix/django-sshkey
 def test_same_key_different_user(self):
   key1 = UserKey(
     user=self.user1,
     name='name1',
     key=open(self.key1_path + '.pub').read(),
   )
   key1.full_clean()
   key1.save()
   key2 = UserKey(
     user=self.user2,
     name='name2',
     key=open(self.key1_path + '.pub').read(),
   )
   self.assertRaises(ValidationError, key2.full_clean)
コード例 #16
0
ファイル: tests.py プロジェクト: ClemsonSoCUnix/django-sshkey
 def test_same_name_different_user(self):
   key1 = UserKey(
     user=self.user1,
     name='name',
     key=open(self.key1_path + '.pub').read(),
   )
   key1.full_clean()
   key1.save()
   key2 = UserKey(
     user=self.user2,
     name='name',
     key=open(self.key2_path + '.pub').read(),
   )
   key2.full_clean()
   key2.save()
コード例 #17
0
ファイル: tests.py プロジェクト: rantecki/django-sshkey
 def test_same_name_different_user(self):
     key1 = UserKey(
         user=self.user1,
         name='name',
         key=open(self.key1_path + '.pub').read(),
     )
     key1.full_clean()
     key1.save()
     key2 = UserKey(
         user=self.user2,
         name='name',
         key=open(self.key2_path + '.pub').read(),
     )
     key2.full_clean()
     key2.save()
コード例 #18
0
ファイル: tests.py プロジェクト: rantecki/django-sshkey
 def test_export(self):
     key = UserKey(
         user=self.user1,
         name='name',
         key=open(self.key1_path + '.pub').read(),
     )
     key.full_clean()
     key.save()
     export_path = os.path.join(self.key_dir, 'export')
     import_path = os.path.join(self.key_dir, 'import')
     with open(export_path, 'w') as f:
         f.write(key.export('PEM'))
     ssh_key_import(export_path, import_path, 'PEM')
     self.assertEqual(
         open(import_path).read().split()[:2],
         open(self.key1_path + '.pub').read().split()[:2])