# Copyright (c) Huawei Technologies Co., Ltd. 2026-2026. All rights reserved.
# MindIE is licensed under Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
#         `http://license.coscl.org.cn/MulanPSL2`
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.

import unittest

from olc.encryptor.aes_encryptor import AesEncryptor


class TestAesEncryptor(unittest.TestCase):
    def test_encrypt_decrypt(self):
        encryptor = AesEncryptor("test_password")
        plaintext = "Hello, World!"
        
        encrypted = encryptor.encrypt(plaintext)
        decrypted = encryptor.decrypt(encrypted)
        
        self.assertEqual(decrypted, plaintext)

    def test_empty_string(self):
        encryptor = AesEncryptor("test_password")
        
        encrypted = encryptor.encrypt("")
        decrypted = encryptor.decrypt(encrypted)
        
        self.assertEqual(decrypted, "")

    def test_special_characters(self):
        encryptor = AesEncryptor("password123")
        plaintext = "测试文本@#$%^&*()_+"
        
        encrypted = encryptor.encrypt(plaintext)
        decrypted = encryptor.decrypt(encrypted)
        
        self.assertEqual(decrypted, plaintext)

    def test_different_passwords(self):
        encryptor1 = AesEncryptor("password1")
        encryptor2 = AesEncryptor("password2")
        plaintext = "secret data"
        
        encrypted = encryptor1.encrypt(plaintext)
        self.assertNotEqual(encryptor2.decrypt(encrypted), plaintext)

if __name__ == "__main__":
    unittest.main()