Exemple #1
0
def create_thrift(name=None, wallet=None, base_dir_path=None, port=7777, client=None):

    endpoint_args = {'onlyListener': True}
    if wallet:
        endpoint_args['seed'] = wallet._signerById(wallet.defaultId).seed
    else:
        wallet = Wallet(name)
        wallet.addIdentifier(signer=SimpleSigner(seed=THRIFT_SEED))
        endpoint_args['seed'] = THRIFT_SEED

    if client is None:
        client = create_client(base_dir_path=None, client_class=TestClient)

    agent = ThriftAgent(name=name or 'Thrift Bank',
                        basedirpath=base_dir_path,
                        client=client,
                        wallet=wallet,
                        port=port,
                        endpointArgs=endpoint_args)

    agent._invites = {
        "77fbf9dc8c8e6acde33de98c6d747b28c": (1, "Alice"),
        "ousezru20ic4yz3j074trcgthwlsnfsef": (2, "Bob")
    }

    return agent
Exemple #2
0
def create_faber(name=None,
                 wallet=None,
                 base_dir_path=None,
                 port=5555,
                 client=None):

    if client is None:
        client = create_client(base_dir_path=None, client_class=TestClient)

    endpoint_args = {'onlyListener': True}
    if wallet:
        endpoint_args['seed'] = wallet._signerById(wallet.defaultId).seed
    else:
        wallet = Wallet(name)
        wallet.addIdentifier(signer=FABER_SIGNER)
        endpoint_args['seed'] = FABER_SEED

    agent = WalletedAgent(name=name or "Faber College",
                          basedirpath=base_dir_path,
                          client=client,
                          wallet=wallet,
                          port=port,
                          endpointArgs=endpoint_args)

    agent._invites = {
        "b1134a647eb818069c089e7694f63e6d": (1, "Alice"),
        "2a2eb72eca8b404e8d412c5bf79f2640": (2, "Carol"),
        "7513d1397e87cada4214e2a650f603eb": (3, "Frank"),
        "710b78be79f29fc81335abaa4ee1c5e8": (4, "Bob")
    }

    transcript_def = AttribDef('Transcript', [
        AttribType('student_name', encode=True),
        AttribType('ssn', encode=True),
        AttribType('degree', encode=True),
        AttribType('year', encode=True),
        AttribType('status', encode=True)
    ])

    agent.add_attribute_definition(transcript_def)

    backend = MockBackendSystem(transcript_def)

    backend.add_record(1,
                       student_name="Alice Garcia",
                       ssn="123-45-6789",
                       degree="Bachelor of Science, Marketing",
                       year="2015",
                       status="graduated")

    backend.add_record(2,
                       student_name="Carol Atkinson",
                       ssn="783-41-2695",
                       degree="Bachelor of Science, Physics",
                       year="2012",
                       status="graduated")

    backend.add_record(3,
                       student_name="Frank Jeffrey",
                       ssn="996-54-1211",
                       degree="Bachelor of Arts, History",
                       year="2013",
                       status="dropped")

    backend.add_record(4,
                       student_name="Bob Richards",
                       ssn="151-44-5876",
                       degree="MBA, Finance",
                       year="2015",
                       status="graduated")

    agent.set_issuer_backend(backend)

    return agent
Exemple #3
0
def create_acme(name=None, wallet=None, base_dir_path=None, port=6666, client=None):
    if client is None:
        client = create_client(base_dir_path=None, client_class=TestClient)

    endpoint_args = {'onlyListener': True}
    if wallet:
        endpoint_args['seed'] = wallet._signerById(wallet.defaultId).seed
    else:
        wallet = Wallet(name)
        wallet.addIdentifier(signer=ACME_SIGNER)
        endpoint_args['seed'] = ACME_SEED

    agent = AcmeAgent(name=name or "Acme Corp",
                      basedirpath=base_dir_path,
                      client=client,
                      wallet=wallet,
                      port=port,
                      endpointArgs=endpoint_args)

    # maps invitation nonces to internal ids
    agent._invites = {
        "57fbf9dc8c8e6acde33de98c6d747b28c": (1, "Alice"),
        "3a2eb72eca8b404e8d412c5bf79f2640": (2, "Carol"),
        "8513d1397e87cada4214e2a650f603eb": (3, "Frank"),
        "810b78be79f29fc81335abaa4ee1c5e8": (4, "Bob")
    }

    job_cert_def = AttribDef('Job-Certificate',
                             [AttribType('first_name', encode=True),
                              AttribType('last_name', encode=True),
                              AttribType('employee_status', encode=True),
                              AttribType('experience', encode=True),
                              AttribType('salary_bracket', encode=True)])

    job_appl_def = AttribDef('Job-Application',
                             [AttribType('first_name', encode=True),
                              AttribType('last_name', encode=True),
                              AttribType('phone_number', encode=True),
                              AttribType('degree', encode=True),
                              AttribType('status', encode=True),
                              AttribType('ssn', encode=True)])

    agent.add_attribute_definition(job_cert_def)
    agent.add_attribute_definition(job_appl_def)

    backend = MockBackendSystem(job_cert_def)
    backend.add_record(1,
                       first_name="Alice",
                       last_name="Garcia",
                       employee_status="Permanent",
                       experience="3 years",
                       salary_bracket="between $50,000 to $100,000")

    backend.add_record(2,
                       first_name="Carol",
                       last_name="Atkinson",
                       employee_status="Permanent",
                       experience="2 years",
                       salary_bracket="between $60,000 to $90,000")

    backend.add_record(3,
                       first_name="Frank",
                       last_name="Jeffrey",
                       employee_status="Temporary",
                       experience="4 years",
                       salary_bracket="between $40,000 to $80,000")

    backend.add_record(4,
                       first_name="Bob",
                       last_name="Richards",
                       employee_status="On Contract",
                       experience="3 years",
                       salary_bracket="between $50,000 to $70,000")

    agent.set_issuer_backend(backend)

    agent._proofRequestsSchema = {
        "Job-Application-v0.2": {
            "name": "Job-Application",
            "version": "0.2",
            "attributes": {
                "first_name": "string",
                "last_name": "string",
                "phone_number": "string",
                "degree": "string",
                "status": "string",
                "ssn": "string"
            },
            "verifiableAttributes": ["degree", "status", "ssn"]
        },
        "Job-Application-v0.3": {
            "name": "Job-Application-2",
            "version": "0.3",
            "attributes": {
                "first_name": "string",
                "last_name": "string",
                "phone_number": "string",
                "degree": "string",
                "status": "string",
                "ssn": "string"
            },
            "verifiableAttributes": ["degree", "status"]
        }
    }

    return agent
Exemple #4
0
def create_acme(name=None,
                wallet=None,
                base_dir_path=None,
                port=6666,
                client=None):
    if client is None:
        client = create_client(base_dir_path=None, client_class=TestClient)

    endpoint_args = {'onlyListener': True}
    if wallet:
        endpoint_args['seed'] = wallet._signerById(wallet.defaultId).seed
    else:
        wallet = Wallet(name)
        wallet.addIdentifier(signer=ACME_SIGNER)
        endpoint_args['seed'] = ACME_SEED

    agent = AcmeAgent(name=name or "Acme Corp",
                      basedirpath=base_dir_path,
                      client=client,
                      wallet=wallet,
                      port=port,
                      endpointArgs=endpoint_args)

    # maps request nonces to internal ids
    agent._invites = {
        "57fbf9dc8c8e6acde33de98c6d747b28c": (1, "Alice"),
        "3a2eb72eca8b404e8d412c5bf79f2640": (2, "Carol"),
        "8513d1397e87cada4214e2a650f603eb": (3, "Frank"),
        "810b78be79f29fc81335abaa4ee1c5e8": (4, "Bob")
    }

    job_cert_def = AttribDef('Job-Certificate', [
        AttribType('first_name', encode=True),
        AttribType('last_name', encode=True),
        AttribType('employee_status', encode=True),
        AttribType('experience', encode=True),
        AttribType('salary_bracket', encode=True)
    ])

    job_appl_def = AttribDef('Job-Application', [
        AttribType('first_name', encode=True),
        AttribType('last_name', encode=True),
        AttribType('phone_number', encode=True),
        AttribType('degree', encode=True),
        AttribType('status', encode=True),
        AttribType('ssn', encode=True)
    ])

    agent.add_attribute_definition(job_cert_def)
    agent.add_attribute_definition(job_appl_def)

    backend = MockBackendSystem(job_cert_def)
    backend.add_record(1,
                       first_name="Alice",
                       last_name="Garcia",
                       employee_status="Permanent",
                       experience="3 years",
                       salary_bracket="between $50,000 to $100,000")

    backend.add_record(2,
                       first_name="Carol",
                       last_name="Atkinson",
                       employee_status="Permanent",
                       experience="2 years",
                       salary_bracket="between $60,000 to $90,000")

    backend.add_record(3,
                       first_name="Frank",
                       last_name="Jeffrey",
                       employee_status="Temporary",
                       experience="4 years",
                       salary_bracket="between $40,000 to $80,000")

    backend.add_record(4,
                       first_name="Bob",
                       last_name="Richards",
                       employee_status="On Contract",
                       experience="3 years",
                       salary_bracket="between $50,000 to $70,000")

    agent.set_issuer_backend(backend)

    agent._proofRequestsSchema = {
        "Job-Application-v0.2": {
            "name": "Job-Application",
            "version": "0.2",
            "attributes": {
                "first_name": "string",
                "last_name": "string",
                "phone_number": "string",
                "degree": "string",
                "status": "string",
                "ssn": "string"
            },
            "verifiableAttributes": ["degree", "status", "ssn"]
        },
        "Job-Application-v0.3": {
            "name": "Job-Application-2",
            "version": "0.3",
            "attributes": {
                "first_name": "string",
                "last_name": "string",
                "phone_number": "string",
                "degree": "string",
                "status": "string",
                "ssn": "string"
            },
            "verifiableAttributes": ["degree", "status"]
        }
    }

    return agent
Exemple #5
0
def create_faber(name=None, wallet=None, base_dir_path=None, port=5555, client=None):

    if client is None:
        client = create_client(base_dir_path=None, client_class=TestClient)

    endpoint_args = {'onlyListener': True}
    if wallet:
        endpoint_args['seed'] = wallet._signerById(wallet.defaultId).seed
    else:
        wallet = Wallet(name)
        wallet.addIdentifier(signer=SimpleSigner(seed=FABER_SEED))
        endpoint_args['seed'] = FABER_SEED

    agent = WalletedAgent(name=name or "Faber College",
                          basedirpath=base_dir_path,
                          client=client,
                          wallet=wallet,
                          port=port,
                          endpointArgs=endpoint_args)

    agent._invites = {
        "b1134a647eb818069c089e7694f63e6d": (1, "Alice"),
        "2a2eb72eca8b404e8d412c5bf79f2640": (2, "Carol"),
        "7513d1397e87cada4214e2a650f603eb": (3, "Frank"),
        "710b78be79f29fc81335abaa4ee1c5e8": (4, "Bob")
    }

    transcript_def = AttribDef('Transcript',
                              [AttribType('student_name', encode=True),
                               AttribType('ssn', encode=True),
                               AttribType('degree', encode=True),
                               AttribType('year', encode=True),
                               AttribType('status', encode=True)])

    agent.add_attribute_definition(transcript_def)

    backend = MockBackendSystem(transcript_def)

    backend.add_record(1,
                       student_name="Alice Garcia",
                       ssn="123-45-6789",
                       degree="Bachelor of Science, Marketing",
                       year="2015",
                       status="graduated")

    backend.add_record(2,
                       student_name="Carol Atkinson",
                       ssn="783-41-2695",
                       degree="Bachelor of Science, Physics",
                       year="2012",
                       status="graduated")

    backend.add_record(3,
                       student_name="Frank Jeffrey",
                       ssn="996-54-1211",
                       degree="Bachelor of Arts, History",
                       year="2013",
                       status="dropped")

    backend.add_record(4,
                       student_name="Bob Richards",
                       ssn="151-44-5876",
                       degree="MBA, Finance",
                       year="2015",
                       status="graduated")

    agent.set_issuer_backend(backend)

    return agent