fork download
  1.  
Success #stdin #stdout 0.02s 9220KB
stdin
# vpn_function_test.py
import uuid
import hashlib

# 간단한 사용자 DB
users = {}

# 사용자 생성 함수
def create_user(username, password):
    user_id = str(uuid.uuid4())
    hashed_pw = hashlib.sha256(password.encode()).hexdigest()
    users[user_id] = {"username": username, "password": hashed_pw, "active": True}
    return user_id

# 사용자 비활성화 함수
def deactivate_user(user_id):
    if user_id in users:
        users[user_id]["active"] = False
        return True
    return False

# 사용자 조회 함수
def get_user(user_id):
    return users.get(user_id, None)

# 활성 사용자 리스트 함수
def list_active_users():
    return [u for u in users.values() if u["active"]]

# ------------------------------
# 테스트 실행
print("=== VPN 관리 기능 테스트 ===")
uid1 = create_user("alice", "mypassword123")
uid2 = create_user("bob", "securepass456")
print("생성된 사용자들:", users)

deactivate_user(uid1)
print("비활성화 후 활성 사용자 목록:", list_active_users())

print("특정 사용자 조회:", get_user(uid2))
stdout
Standard output is empty