<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import XCTest
import Storage

class CertTests: XCTestCase {
    func testCertStore() {
        let certStore = CertStore()
        let cert1 = getCertificate("testcert1")
        let cert2 = getCertificate("testcert2")

        // Check that contains return false for certs not in store.
        XCTAssertFalse(certStore.containsCertificate(cert1))

        // Add cert 1.
        certStore.addCertificate(cert1)

        // Check that the cert is in the store.
        XCTAssert(certStore.containsCertificate(cert1))

        // Check that contains uniquely identifies certs.
        XCTAssertFalse(certStore.containsCertificate(cert2))

        // Check that adding an existing cert has no effect.
        certStore.addCertificate(cert1)
        XCTAssert(certStore.containsCertificate(cert1))
    }

    private func getCertificate(file: String) -> SecCertificateRef {
        let path = NSBundle(forClass: self.dynamicType).pathForResource(file, ofType: "pem")
        let data = NSData(contentsOfFile: path!)
        return SecCertificateCreateWithData(nil, data!)!
    }
}
<commit_msg>Bug 1278053 - Update CertTests<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import XCTest
import Storage

class CertTests: XCTestCase {
    func testCertStore() {
        let certStore = CertStore()
        let origin1 = "www.mozilla.org:80"
        let origin2 = "people.mozilla.org:80"
        let cert1 = getCertificate("testcert1")
        let cert2 = getCertificate("testcert2")

        // Check that contains return false for certs not in store.
        XCTAssertFalse(certStore.containsCertificate(cert1, forOrigin: origin1))

        // Add a certificate.
        certStore.addCertificate(cert1, forOrigin: origin1)

        // Check that the cert is in the store.
        XCTAssert(certStore.containsCertificate(cert1, forOrigin: origin1))

        // Check that the cert is unique to the origin.
        XCTAssertFalse(certStore.containsCertificate(cert1, forOrigin: origin2))
        XCTAssertFalse(certStore.containsCertificate(cert2, forOrigin: origin1))

        // Add a different certificate for the same origin.
        certStore.addCertificate(cert2, forOrigin: origin1)

        // Check that adding a cert for an existing origin doesn't do a replace.
        XCTAssert(certStore.containsCertificate(cert1, forOrigin: origin1))
        XCTAssert(certStore.containsCertificate(cert2, forOrigin: origin1))

        // Check that adding an existing cert has no effect.
        certStore.addCertificate(cert1, forOrigin: origin1)
        XCTAssert(certStore.containsCertificate(cert1, forOrigin: origin1))
    }

    private func getCertificate(file: String) -> SecCertificateRef {
        let path = NSBundle(forClass: self.dynamicType).pathForResource(file, ofType: "pem")
        let data = NSData(contentsOfFile: path!)
        return SecCertificateCreateWithData(nil, data!)!
    }
}

{'fraction_non_alphanumeric': 0.08629595867517471, 'fraction_numerical': 0.01701610452749924, 'mean_word_length': 3.0742574257425743, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5367516', 'n_tokens_mistral': 929, 'n_tokens_neox': 892, 'n_words': 283}