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
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)