コード例 #1
0
ファイル: test_chap.py プロジェクト: tangwenji/ceph-iscsi
    def test_chap_encryption(self):
        private_key = rsa.generate_private_key(public_exponent=65537,
                                               key_size=2048,
                                               backend=default_backend())
        priv_pem = private_key.private_bytes(
            encoding=serialization.Encoding.PEM,
            format=serialization.PrivateFormat.TraditionalOpenSSL,
            encryption_algorithm=serialization.NoEncryption())
        priv_key_file = tempfile.mkstemp()
        with open(priv_key_file[1], "wb") as kf:
            kf.write(priv_pem)

        pub_pem = private_key.public_key().public_bytes(
            encoding=serialization.Encoding.PEM,
            format=serialization.PublicFormat.SubjectPublicKeyInfo)
        pub_key_file = tempfile.mkstemp()
        with open(pub_key_file[1], "wb") as kf:
            kf.write(pub_pem)

        settings.config.priv_key = priv_key_file[1]
        settings.config.pub_key = pub_key_file[1]
        settings.config.ceph_config_dir = ""

        chap = CHAP("")
        chap._set_chap_str("username/passwordverylonglong")

        chap2 = CHAP(chap._get_chap_str())
        self.assertEqual(chap2._get_chap_str(),
                         "username/passwordverylonglong")
コード例 #2
0
ファイル: test_chap.py プロジェクト: tangwenji/ceph-iscsi
 def test_chap_no_encryption(self):
     chap = CHAP("")
     chap._set_chap_str("username/password")
     self.assertEqual(chap._get_chap_str(), "username/password")