зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1120393 - unittest to ensure nsITransportSecurityInfo.errorCode is correctly serialized. r=keeler
This commit is contained in:
Родитель
0b9afb21b8
Коммит
cb76e55fd8
|
@ -40,6 +40,21 @@ function test_cert_list_serialization() {
|
|||
do_check_true(certList.equals(deserialized));
|
||||
}
|
||||
|
||||
function test_security_info_serialization(securityInfo, expectedErrorCode) {
|
||||
// Serialize the securityInfo to a string
|
||||
let serHelper = Cc["@mozilla.org/network/serialization-helper;1"]
|
||||
.getService(Ci.nsISerializationHelper);
|
||||
let serialized = serHelper.serializeToString(securityInfo);
|
||||
|
||||
// Deserialize from the string and compare to the original object
|
||||
let deserialized = serHelper.deserializeObject(serialized);
|
||||
deserialized.QueryInterface(Ci.nsITransportSecurityInfo);
|
||||
do_check_eq(securityInfo.securityState, deserialized.securityState);
|
||||
do_check_eq(securityInfo.errorMessage, deserialized.errorMessage);
|
||||
do_check_eq(securityInfo.errorCode, expectedErrorCode);
|
||||
do_check_eq(deserialized.errorCode, expectedErrorCode);
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
do_get_profile();
|
||||
add_tls_server_setup("BadCertServer");
|
||||
|
@ -62,6 +77,7 @@ function run_test() {
|
|||
"good.include-subdomains.pinning.example.com", Cr.NS_OK, null,
|
||||
function withSecurityInfo(aTransportSecurityInfo) {
|
||||
aTransportSecurityInfo.QueryInterface(Ci.nsITransportSecurityInfo);
|
||||
test_security_info_serialization(aTransportSecurityInfo, 0);
|
||||
do_check_eq(aTransportSecurityInfo.failedCertChain, null);
|
||||
}
|
||||
);
|
||||
|
@ -73,6 +89,7 @@ function run_test() {
|
|||
null,
|
||||
function withSecurityInfo(securityInfo) {
|
||||
securityInfo.QueryInterface(Ci.nsITransportSecurityInfo);
|
||||
test_security_info_serialization(securityInfo, SEC_ERROR_EXPIRED_CERTIFICATE);
|
||||
do_check_neq(securityInfo.failedCertChain, null);
|
||||
let originalCertChain = build_cert_chain(["expired-ee", "test-ca"]);
|
||||
do_check_true(originalCertChain.equals(securityInfo.failedCertChain));
|
||||
|
@ -86,6 +103,7 @@ function run_test() {
|
|||
null,
|
||||
function withSecurityInfo(securityInfo) {
|
||||
securityInfo.QueryInterface(Ci.nsITransportSecurityInfo);
|
||||
test_security_info_serialization(securityInfo, SEC_ERROR_INADEQUATE_KEY_USAGE);
|
||||
do_check_neq(securityInfo.failedCertChain, null);
|
||||
let originalCertChain = build_cert_chain(["inadequatekeyusage-ee", "test-ca"]);
|
||||
do_check_true(originalCertChain.equals(securityInfo.failedCertChain));
|
||||
|
|
Загрузка…
Ссылка в новой задаче