33 lines
1.1 KiB
Go
33 lines
1.1 KiB
Go
package license
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestOpenSSLDecryptUserKey(t *testing.T) {
|
|
cipherText := "U2FsdGVkX18Zsq52FPbB7FS1QM7CwWh+t1Esi96gUMFILJD0vZXM69uQBC4sP7TjLVOiJPZt0KIq17iql+hXehLCVSbCEhwKKm+zNab+u2Swah63A52hz0KMJXddLRZ6vanmP2goLTzY7749HsFVRDq+3bdbi8fdUZCpAsSTEiqC2cRTpF5WVh0SHt1wX/i42YSQgOYPeXQtg+lRx/URk4p7lYSVQOYWXglp99kO+Va1ADoNcTgrfz3aaAxAkj0S"
|
|
|
|
// Passing empty cryptoKey triggers internalSecretKey() automatically
|
|
info, err := ValidateAndParseLicense(cipherText, "")
|
|
if err != nil {
|
|
t.Fatalf("Validation failed: %v", err)
|
|
}
|
|
|
|
if info.Mabvbh != "84006" {
|
|
t.Errorf("Expected Mabvbh 84006, got %s", info.Mabvbh)
|
|
}
|
|
if info.Key != "web_giao_ban" {
|
|
t.Errorf("Expected Key web_giao_ban, got %s", info.Key)
|
|
}
|
|
if info.TenBV != "Trà Cú" {
|
|
t.Errorf("Expected TenBV Trà Cú, got %s", info.TenBV)
|
|
}
|
|
if info.DateExpires != "2027-01-30" {
|
|
t.Errorf("Expected DateExpires 2027-01-30, got %s", info.DateExpires)
|
|
}
|
|
if !info.IsValid {
|
|
t.Errorf("Expected IsValid true, got false (%s)", info.StatusMessage)
|
|
}
|
|
t.Logf("Decrypted successfully: %+v", info)
|
|
}
|