Spaces:
Running
Running
File size: 1,740 Bytes
c2321bb d291e63 c2321bb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
#!/usr/bin/env python3
"""
Test script for Hugging Face token validation
"""
import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'scripts'))
from validate_hf_token import validate_hf_token
def test_token_validation():
"""Test the token validation function."""
# Test with a valid token (you can replace this with your own token for testing)
# Note: This test will fail if the token is invalid - replace with your own token for testing
test_token = "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"
print("Testing token validation...")
print(f"Token: {test_token[:10]}...")
success, username, error = validate_hf_token(test_token)
if success:
print(f"β
Token validation successful!")
print(f"Username: {username}")
else:
print(f"β Token validation failed: {error}")
return success
def test_invalid_token():
"""Test with an invalid token."""
invalid_token = "hf_invalid_token_for_testing"
print("\nTesting invalid token...")
success, username, error = validate_hf_token(invalid_token)
if not success:
print(f"β
Correctly rejected invalid token: {error}")
else:
print(f"β Unexpectedly accepted invalid token")
return not success
if __name__ == "__main__":
print("π§ͺ Testing Hugging Face Token Validation")
print("=" * 50)
# Test valid token
valid_result = test_token_validation()
# Test invalid token
invalid_result = test_invalid_token()
print("\n" + "=" * 50)
if valid_result and invalid_result:
print("β
All tests passed!")
else:
print("β Some tests failed!")
sys.exit(1) |