コード例 #1
0
def send_attrib(be, do, poolNodesStarted, trusteeCli):

    valid_identifier = createUuidIdentifier()
    invalid_identifier = createUuidIdentifier()
    addNym(be, do, trusteeCli, idr=valid_identifier)

    parameters = {
        'attrib_name':
        attrib_name,
        'valid_dest':
        valid_identifier,
        'invalid_dest':
        invalid_identifier,
        'raw':
        json.dumps({attrib_name: {
            'dayOfMonth': 23,
            'year': 1984,
            'month': 5
        }})
    }

    be(trusteeCli)
    do('send ATTRIB dest={valid_dest} raw={raw}',
       mapper=parameters,
       expect=ATTRIBUTE_ADDED,
       within=2)

    return parameters
コード例 #2
0
def test_send_get_schema_fails_with_invalid_dest(be, do, poolNodesStarted,
                                                 trusteeCli, send_schema):

    uuid_identifier = createUuidIdentifier()
    do('send GET_SCHEMA dest={} name=invalid version=1.0'.format(
        uuid_identifier),
       expect=SCHEMA_NOT_FOUND,
       within=5)
コード例 #3
0
def testSendGetNymFailsForNotExistingUuidDest(be, do, poolNodesStarted,
                                              trusteeCli):

    parameters = {'dest': createUuidIdentifier()}

    be(trusteeCli)
    do('send GET_NYM dest={dest}',
       mapper=parameters,
       expect=NYM_NOT_FOUND,
       within=2)
コード例 #4
0
def testSendGetNymFailsForNotExistingUuidDest(
        be, do, poolNodesStarted, trusteeCli):

    parameters = {
        'dest': createUuidIdentifier()
    }

    be(trusteeCli)
    do('send GET_NYM dest={dest}',
       mapper=parameters, expect=NYM_NOT_FOUND, within=2)
コード例 #5
0
def testSendNymFailsIfUuidIdentifierIsHexEncoded(
        be, do, poolNodesStarted, trusteeCli):

    parameters = {
        'dest': friendlyToHexStr(createUuidIdentifier()),
        'role': Roles.TRUST_ANCHOR.name
    }

    be(trusteeCli)
    do('send NYM dest={dest} role={role}',
       mapper=parameters, expect=ERROR, within=2)
コード例 #6
0
def testSendNymSucceedsForUuidIdentifierAndOmittedVerkey(
        be, do, poolNodesStarted, trusteeCli):

    parameters = {
        'dest': createUuidIdentifier(),
        'role': Roles.TRUST_ANCHOR.name
    }

    be(trusteeCli)
    do('send NYM dest={dest} role={role}',
       mapper=parameters, expect=NYM_ADDED, within=2)
コード例 #7
0
def testSendAttribFailsForNotExistingUuidDest(be, do, poolNodesStarted,
                                              trusteeCli):

    uuidIdentifier = createUuidIdentifier()

    parameters = {'dest': uuidIdentifier, 'raw': json.dumps({'name': 'Alice'})}

    be(trusteeCli)
    do('send ATTRIB dest={dest} raw={raw}',
       mapper=parameters,
       expect=ERROR,
       within=2)
コード例 #8
0
def testSendNymHasInvalidSyntaxForUuidIdentifierAndEmptyVerkey(
        be, do, poolNodesStarted, trusteeCli):

    parameters = {
        'dest': createUuidIdentifier(),
        'verkey': '',
        'role': Roles.TRUST_ANCHOR.name
    }

    be(trusteeCli)
    do('send NYM dest={dest} role={role} verkey={verkey}',
       mapper=parameters, expect=INVALID_SYNTAX, within=2)
コード例 #9
0
def testSendGetNymFailsIfDestIsInvalid(be, do, poolNodesStarted, trusteeCli):

    uuidIdentifier = createUuidIdentifier()
    invalidIdentifier = uuidIdentifier[:-4]

    parameters = {'dest': invalidIdentifier}

    be(trusteeCli)
    do('send GET_NYM dest={dest}',
       mapper=parameters,
       expect="b58 decoded value length",
       within=2)
コード例 #10
0
def testSendNymFailsIfUuidIdentifierIsHexEncoded(be, do, poolNodesStarted,
                                                 trusteeCli):

    parameters = {
        'dest': friendlyToHexStr(createUuidIdentifier()),
        'role': Roles.TRUST_ANCHOR.name
    }

    be(trusteeCli)
    do('send NYM dest={dest} role={role}',
       mapper=parameters,
       expect=ERROR,
       within=2)
コード例 #11
0
def testSendNymSucceedsForUuidIdentifierAndOmittedVerkey(
        be, do, poolNodesStarted, trusteeCli):

    parameters = {
        'dest': createUuidIdentifier(),
        'role': Roles.TRUST_ANCHOR.name
    }

    be(trusteeCli)
    do('send NYM dest={dest} role={role}',
       mapper=parameters,
       expect=NYM_ADDED,
       within=2)
コード例 #12
0
def testSendNymFailsIfIdentifierContainsNonBase58Characters(
        be, do, poolNodesStarted, trusteeCli):

    uuidIdentifier = createUuidIdentifier()

    parameters = {
        'dest': uuidIdentifier[:5] + '/' + uuidIdentifier[6:],
        'role': Roles.TRUST_ANCHOR.name
    }

    be(trusteeCli)
    do('send NYM dest={dest} role={role}',
       mapper=parameters, expect=ERROR, within=2)
コード例 #13
0
def testSendAttribSucceedsForExistingUuidDest(be, do, poolNodesStarted,
                                              trusteeCli):

    uuidIdentifier = createUuidIdentifier()
    addNym(be, do, trusteeCli, idr=uuidIdentifier)

    parameters = {'dest': uuidIdentifier, 'raw': json.dumps({'name': 'Alice'})}

    be(trusteeCli)
    do('send ATTRIB dest={dest} raw={raw}',
       mapper=parameters,
       expect=ATTRIBUTE_ADDED,
       within=2)
コード例 #14
0
def testSendAttribHasInvalidSyntaxIfParametersOrderIsWrong(
        be, do, poolNodesStarted, trusteeCli):

    uuidIdentifier = createUuidIdentifier()
    addNym(be, do, trusteeCli, idr=uuidIdentifier)

    parameters = {'dest': uuidIdentifier, 'raw': json.dumps({'name': 'Alice'})}

    be(trusteeCli)
    do('send ATTRIB raw={raw} dest={dest}',
       mapper=parameters,
       expect=INVALID_SYNTAX,
       within=2)
コード例 #15
0
def testSendAttribFailsForRawWithEndpointBeingEmptyString(
        be, do, poolNodesStarted, trusteeCli):

    uuidIdentifier = createUuidIdentifier()
    addNym(be, do, trusteeCli, idr=uuidIdentifier)

    parameters = {'dest': uuidIdentifier, 'raw': json.dumps({'endpoint': ''})}

    be(trusteeCli)
    do('send ATTRIB dest={dest} raw={raw}',
       mapper=parameters,
       expect=ERROR,
       within=2)
コード例 #16
0
def testSendAttribHasInvalidSyntaxIfEncIsEmpty(be, do, poolNodesStarted,
                                               trusteeCli):

    uuidIdentifier = createUuidIdentifier()
    addNym(be, do, trusteeCli, idr=uuidIdentifier)

    parameters = {'dest': uuidIdentifier, 'enc': ''}

    be(trusteeCli)
    do('send ATTRIB dest={dest} enc={enc}',
       mapper=parameters,
       expect=INVALID_SYNTAX,
       within=2)
コード例 #17
0
def testSendAttribSucceedsForRawWithEndpointWithoutProperties(
        be, do, poolNodesStarted, trusteeCli):

    uuidIdentifier = createUuidIdentifier()
    addNym(be, do, trusteeCli, idr=uuidIdentifier)

    parameters = {'dest': uuidIdentifier, 'raw': json.dumps({'endpoint': {}})}

    be(trusteeCli)
    do('send ATTRIB dest={dest} raw={raw}',
       mapper=parameters,
       expect=ATTRIBUTE_ADDED,
       within=2)
コード例 #18
0
def testSendAttribFailsIfRawIsHumanReadableText(be, do, poolNodesStarted,
                                                trusteeCli):

    uuidIdentifier = createUuidIdentifier()
    addNym(be, do, trusteeCli, idr=uuidIdentifier)

    parameters = {'dest': uuidIdentifier, 'raw': 'This is not a json.'}

    be(trusteeCli)
    do('send ATTRIB dest={dest} raw={raw}',
       mapper=parameters,
       expect=ERROR,
       within=2)
コード例 #19
0
def testSendGetNymFailsIfDestIsInvalid(
        be, do, poolNodesStarted, trusteeCli):

    uuidIdentifier = createUuidIdentifier()
    invalidIdentifier = uuidIdentifier[:-4]

    parameters = {
        'dest': invalidIdentifier
    }

    be(trusteeCli)
    do('send GET_NYM dest={dest}',
       mapper=parameters, expect="b58 decoded value length", within=2)
コード例 #20
0
def testSendAttribFailsIfRawIsDecimalNumber(be, do, poolNodesStarted,
                                            trusteeCli):

    uuidIdentifier = createUuidIdentifier()
    addNym(be, do, trusteeCli, idr=uuidIdentifier)

    parameters = {'dest': uuidIdentifier, 'raw': 42}

    be(trusteeCli)
    do('send ATTRIB dest={dest} raw={raw}',
       mapper=parameters,
       expect=ERROR,
       within=2)
コード例 #21
0
def testSendAttribFailsIfRawContainsNoAttrs(be, do, poolNodesStarted,
                                            trusteeCli):

    uuidIdentifier = createUuidIdentifier()
    addNym(be, do, trusteeCli, idr=uuidIdentifier)

    parameters = {'dest': uuidIdentifier, 'raw': json.dumps({})}

    be(trusteeCli)
    do('send ATTRIB dest={dest} raw={raw}',
       mapper=parameters,
       expect=ERROR,
       within=2)
コード例 #22
0
def testSendNymHasInvalidSyntaxForUuidIdentifierAndEmptyVerkey(
        be, do, poolNodesStarted, trusteeCli):

    parameters = {
        'dest': createUuidIdentifier(),
        'verkey': '',
        'role': Roles.TRUST_ANCHOR.name
    }

    be(trusteeCli)
    do('send NYM dest={dest} role={role} verkey={verkey}',
       mapper=parameters,
       expect=INVALID_SYNTAX,
       within=2)
コード例 #23
0
def testSendNymFailsIfIdentifierContainsNonBase58Characters(
        be, do, poolNodesStarted, trusteeCli):

    uuidIdentifier = createUuidIdentifier()

    parameters = {
        'dest': uuidIdentifier[:5] + '/' + uuidIdentifier[6:],
        'role': Roles.TRUST_ANCHOR.name
    }

    be(trusteeCli)
    do('send NYM dest={dest} role={role}',
       mapper=parameters,
       expect=ERROR,
       within=2)
コード例 #24
0
def testSendAttribFailsIfRawIsHex(be, do, poolNodesStarted, trusteeCli):

    uuidIdentifier = createUuidIdentifier()
    addNym(be, do, trusteeCli, idr=uuidIdentifier)

    parameters = {
        'dest': uuidIdentifier,
        'raw': hexlify(randombytes(32)).decode()
    }

    be(trusteeCli)
    do('send ATTRIB dest={dest} raw={raw}',
       mapper=parameters,
       expect=ERROR,
       within=2)
コード例 #25
0
def testSendAttribFailsIfRawIsBrokenJson(be, do, poolNodesStarted, trusteeCli):

    uuidIdentifier = createUuidIdentifier()
    addNym(be, do, trusteeCli, idr=uuidIdentifier)

    validJson = json.dumps({'name': 'Alice'})

    brokenJson = validJson[:-1]

    parameters = {'dest': uuidIdentifier, 'raw': brokenJson}

    be(trusteeCli)
    do('send ATTRIB dest={dest} raw={raw}',
       mapper=parameters,
       expect=ERROR,
       within=2)
コード例 #26
0
def testSendAttribFailsForHashLongerThanSha256(be, do, poolNodesStarted,
                                               trusteeCli):

    uuidIdentifier = createUuidIdentifier()
    addNym(be, do, trusteeCli, idr=uuidIdentifier)

    parameters = {
        'dest': uuidIdentifier,
        'hash': hexlify(randombytes(33)).decode()
    }

    be(trusteeCli)
    do('send ATTRIB dest={dest} hash={hash}',
       mapper=parameters,
       expect=ERROR,
       within=2)
コード例 #27
0
def testSendAttribFailsForBase64Hash(be, do, poolNodesStarted, trusteeCli):

    uuidIdentifier = createUuidIdentifier()
    addNym(be, do, trusteeCli, idr=uuidIdentifier)

    raw = json.dumps({'name': 'Alice'})

    hash = sha256(raw.encode()).digest()

    parameters = {'dest': uuidIdentifier, 'hash': b64encode(hash).decode()}

    be(trusteeCli)
    do('send ATTRIB dest={dest} hash={hash}',
       mapper=parameters,
       expect=ERROR,
       within=2)
コード例 #28
0
def testSendAttribHasInvalidSyntaxIfUnknownParameterIsPassed(
        be, do, poolNodesStarted, trusteeCli):

    uuidIdentifier = createUuidIdentifier()
    addNym(be, do, trusteeCli, idr=uuidIdentifier)

    parameters = {
        'dest': uuidIdentifier,
        'raw': json.dumps({'name': 'Alice'}),
        'extra': 42
    }

    be(trusteeCli)
    do('send ATTRIB dest={dest} raw={raw} extra={extra}',
       mapper=parameters,
       expect=INVALID_SYNTAX,
       within=2)
コード例 #29
0
def testSendAttribSucceedsForHexHashWithLettersInBothCases(
        be, do, poolNodesStarted, trusteeCli):

    uuidIdentifier = createUuidIdentifier()
    addNym(be, do, trusteeCli, idr=uuidIdentifier)

    parameters = {
        'dest': uuidIdentifier,
        'hash':
        '6d4a333838d0ef96756cccC680AF2531075C512502Fb68c5503c63d93de859b3'
    }

    be(trusteeCli)
    do('send ATTRIB dest={dest} hash={hash}',
       mapper=parameters,
       expect=ATTRIBUTE_ADDED,
       within=2)
コード例 #30
0
def testSendAttribSucceedsForRawWithEndpointWithHaContainingIpAddrAndPort(
        be, do, poolNodesStarted, trusteeCli):

    uuidIdentifier = createUuidIdentifier()
    addNym(be, do, trusteeCli, idr=uuidIdentifier)

    parameters = {
        'dest': uuidIdentifier,
        'raw': json.dumps({'endpoint': {
            'ha': '52.11.117.186:6321'
        }})
    }

    be(trusteeCli)
    do('send ATTRIB dest={dest} raw={raw}',
       mapper=parameters,
       expect=ATTRIBUTE_ADDED,
       within=2)
コード例 #31
0
def testSendAttribFailsForRawWithEndpointWithHaIfSomeIpCompHigherThanUpperBound(
        be, do, poolNodesStarted, trusteeCli):

    uuidIdentifier = createUuidIdentifier()
    addNym(be, do, trusteeCli, idr=uuidIdentifier)

    parameters = {
        'dest': uuidIdentifier,
        'raw': json.dumps({'endpoint': {
            'ha': '52.11.256.186:6321'
        }})
    }

    be(trusteeCli)
    do('send ATTRIB dest={dest} raw={raw}',
       mapper=parameters,
       expect=ERROR,
       within=2)
コード例 #32
0
def testSendAttribFailsForRawWithEndpointWithHaIfPortHasWrongFormat(
        be, do, poolNodesStarted, trusteeCli):

    uuidIdentifier = createUuidIdentifier()
    addNym(be, do, trusteeCli, idr=uuidIdentifier)

    parameters = {
        'dest': uuidIdentifier,
        'raw': json.dumps({'endpoint': {
            'ha': '52.11.117.186:ninety'
        }})
    }

    be(trusteeCli)
    do('send ATTRIB dest={dest} raw={raw}',
       mapper=parameters,
       expect=ERROR,
       within=2)
コード例 #33
0
def testSendAttribSucceedsForHexSha256Hash(be, do, poolNodesStarted,
                                           trusteeCli):

    uuidIdentifier = createUuidIdentifier()
    addNym(be, do, trusteeCli, idr=uuidIdentifier)

    raw = json.dumps({'name': 'Alice'})

    parameters = {
        'dest': uuidIdentifier,
        'hash': sha256(raw.encode()).hexdigest()
    }

    be(trusteeCli)
    do('send ATTRIB dest={dest} hash={hash}',
       mapper=parameters,
       expect=ATTRIBUTE_ADDED,
       within=2)
コード例 #34
0
def testSendAttribFailsForRawWithEndpointWithHaContainingDomainNameOnly(
        be, do, poolNodesStarted, trusteeCli):

    uuidIdentifier = createUuidIdentifier()
    addNym(be, do, trusteeCli, idr=uuidIdentifier)

    parameters = {
        'dest': uuidIdentifier,
        'raw': json.dumps({'endpoint': {
            'ha': 'sovrin.org'
        }})
    }

    be(trusteeCli)
    do('send ATTRIB dest={dest} raw={raw}',
       mapper=parameters,
       expect=ERROR,
       within=2)
コード例 #35
0
def testSendAttribFailsForRawWithEndpointWithHaBeingHumanReadableText(
        be, do, poolNodesStarted, trusteeCli):

    uuidIdentifier = createUuidIdentifier()
    addNym(be, do, trusteeCli, idr=uuidIdentifier)

    parameters = {
        'dest': uuidIdentifier,
        'raw': json.dumps({'endpoint': {
            'ha': 'This is not a host address.'
        }})
    }

    be(trusteeCli)
    do('send ATTRIB dest={dest} raw={raw}',
       mapper=parameters,
       expect=ERROR,
       within=2)
コード例 #36
0
def testSendAttribFailsIfDestIsPassedInHexFormat(be, do, poolNodesStarted,
                                                 trusteeCli):

    uuidIdentifier = createUuidIdentifier()
    addNym(be, do, trusteeCli, idr=uuidIdentifier)

    hexEncodedUuidIdentifier = hexlify(friendlyToRaw(uuidIdentifier)).decode()

    parameters = {
        'dest': hexEncodedUuidIdentifier,
        'raw': json.dumps({'name': 'Alice'})
    }

    be(trusteeCli)
    do('send ATTRIB dest={dest} raw={raw}',
       mapper=parameters,
       expect=ERROR,
       within=2)
コード例 #37
0
def test_send_get_schema_fails_with_invalid_dest(
        be, do, poolNodesStarted, trusteeCli, send_schema):

    uuid_identifier = createUuidIdentifier()
    do('send GET_SCHEMA dest={} name=invalid version=1.0'.format(uuid_identifier),
            expect=SCHEMA_NOT_FOUND, within=5)