<commit_before>#!/usr/bin/env python

from __future__ import print_function
from subprocess import check_call
import os, sys

scriptPath = os.path.dirname(__file__)

if not os.path.exists("basicAuthTest"):
    os.makedirs("basicAuthTest")

testXML = """<Test>
  <IdentityCert>IdentityProviderPrivateKey.xml</IdentityCert>
  <UserCert>UserPublicKey.xml</UserCert>
  <Key>PrototypePublicKey.xml</Key>
</Tests>"""

check_call([os.path.join(scriptPath, "createPrincipal.py"), "3", "IdentityProvider"])
check_call(["mv", "IdentityProviderPrivateKey.xml", "IdentityProviderPublicKey.xml", "basicAuthTest"])

check_call([os.path.join(scriptPath, "createPrincipal.py"), "--policyPrivateKey", "basicAuthTest/IdentityProviderPrivateKey.xml", "4", "User"])
check_call([os.path.join(scriptPath, "createEvidenceList.py"), "-o", "basicAuthTest/UserPublicKey.xml", "UserPublicKey.xml"])
check_call([os.path.join(scriptPath, "createEvidenceList.py"), "-o", "basicAuthTest/UserPrivateKey.xml", "UserPrivateKey.xml"])
check_call(["rm", "UserPublicKey.xml", "UserPrivateKey.xml"]) 
check_call(["./cryptUtility.exe", "-GenKey", "RSA1024", "PrototypePrivateKey.xml"])


# cat | grep -v for removing private info and making a public key
with open('PrototypePrivateKey.xml', 'r') as inFile:
    with open('basicAuthTest/PrototypePublicKey.xml', 'wb') as outFile:
        for line in inFile.readline():
            if (not "ds:P" in line) and (not "ds:D" in line) and (not "ds:Q" in line):
                print(line, file=outFile)

check_call(["mv", "PrototypePrivateKey.xml", "basicAuthTest"])

with open('basicAuthTest/tests.xml', 'wb') as testFile:
    print(testXML, file=testFile)
<commit_msg>fixed the PrototypePublicKey.xml output (so it's not one character per line)<commit_after>#!/usr/bin/env python

from __future__ import print_function
from subprocess import check_call
import os, sys

scriptPath = os.path.dirname(__file__)

if not os.path.exists("basicAuthTest"):
    os.makedirs("basicAuthTest")

testXML = """<Test>
  <IdentityCert>IdentityProviderPrivateKey.xml</IdentityCert>
  <UserCert>UserPublicKey.xml</UserCert>
  <Key>PrototypePublicKey.xml</Key>
</Tests>"""

check_call([os.path.join(scriptPath, "createPrincipal.py"), "3", "IdentityProvider"])
check_call(["mv", "IdentityProviderPrivateKey.xml", "IdentityProviderPublicKey.xml", "basicAuthTest"])

check_call([os.path.join(scriptPath, "createPrincipal.py"), "--policyPrivateKey", "basicAuthTest/IdentityProviderPrivateKey.xml", "4", "User"])
check_call([os.path.join(scriptPath, "createEvidenceList.py"), "-o", "basicAuthTest/UserPublicKey.xml", "UserPublicKey.xml"])
check_call([os.path.join(scriptPath, "createEvidenceList.py"), "-o", "basicAuthTest/UserPrivateKey.xml", "UserPrivateKey.xml"])
check_call(["rm", "UserPublicKey.xml", "UserPrivateKey.xml"]) 
check_call(["./cryptUtility.exe", "-GenKey", "RSA1024", "PrototypePrivateKey.xml"])


# cat | grep -v for removing private info and making a public key
with open('PrototypePrivateKey.xml', 'r') as inFile:
    with open('basicAuthTest/PrototypePublicKey.xml', 'wb') as outFile:
        for line in inFile:
            if (not "ds:P" in line) and (not "ds:D" in line) and (not "ds:Q" in line):
                print(line, file=outFile, end='')

check_call(["mv", "PrototypePrivateKey.xml", "basicAuthTest"])

with open('basicAuthTest/tests.xml', 'wb') as testFile:
    print(testXML, file=testFile)

{'fraction_non_alphanumeric': 0.16334310850439882, 'fraction_numerical': 0.0035190615835777126, 'mean_word_length': 6.10625, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 35}, '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': '4023560', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1107, 'n_words': 229}