def test_schema_maximum_attrib(looper, sdk_pool_handle, sdk_wallet_endorser):
    attribs = []
    for i in range(SCHEMA_ATTRIBUTES_LIMIT):
        attribs.append(randomString(NAME_FIELD_LIMIT))

    sdk_write_schema_and_check(looper, sdk_pool_handle, sdk_wallet_endorser,
                               attribs, "business1", "1.9")
Exemplo n.º 2
0
def test_send_schema_one_attrib(looper, sdk_pool_handle,
                                sdk_wallet_trust_anchor):
    sdk_write_schema_and_check(
        looper, sdk_pool_handle,
        sdk_wallet_trust_anchor,
        ["attrib1"],
        "University of Saber",
        "1.0"
    )
Exemplo n.º 3
0
def test_send_schema_multiple_attrib(looper, sdk_pool_handle,
                                     sdk_wallet_trust_anchor):
    sdk_write_schema_and_check(
        looper, sdk_pool_handle,
        sdk_wallet_trust_anchor,
        ["attrib1", "attrib2", "attrib3"],
        "faber",
        "1.4"
    )
Exemplo n.º 4
0
def test_schema_over_maximum_attrib(looper, sdk_pool_handle,
                                    sdk_wallet_trust_anchor):
    attribs = []
    for i in range(SCHEMA_ATTRIBUTES_LIMIT + 1):
        attribs.append('attrib' + str(i))

    with pytest.raises(RequestNackedException) as ex_info:
        sdk_write_schema_and_check(looper, sdk_pool_handle,
                                   sdk_wallet_trust_anchor, attribs,
                                   "business2", "2.0")
    ex_info.match(
        "length should be at most {}".format(SCHEMA_ATTRIBUTES_LIMIT))
Exemplo n.º 5
0
def test_send_by_endorser(looper, sdk_pool_handle, sdk_wallet_new_client, sdk_wallet_endorser):
    # try writing without Endorser by a None-role client
    with pytest.raises(RequestRejectedException):
        sdk_write_schema_and_check(looper, sdk_pool_handle, sdk_wallet_new_client,
                                   ["attr1", "attr2"], "name1", "1.0")

    # write with Endorser
    req_json = sdk_build_schema_request(looper, sdk_wallet_new_client,
                                        ["attr1", "attr2"], "name1", "1.0")
    sdk_submit_and_check_by_endorser(looper, sdk_pool_handle,
                                     sdk_wallet_author=sdk_wallet_new_client, sdk_wallet_endorser=sdk_wallet_endorser,
                                     request_json=req_json)
def test_can_not_send_same_schema(looper, sdk_pool_handle,
                                  sdk_wallet_endorser):
    sdk_write_schema_and_check(looper, sdk_pool_handle, sdk_wallet_endorser,
                               ["attrib1", "attrib2", "attrib3"], "business",
                               "1.8")

    with pytest.raises(RequestRejectedException,
                       match=str(AuthConstraintForbidden())):
        resp = sdk_write_schema_and_check(looper, sdk_pool_handle,
                                          sdk_wallet_endorser,
                                          ["attrib1", "attrib2", "attrib3"],
                                          "business", "1.8")
        validate_write_reply(resp)
Exemplo n.º 7
0
def test_can_not_send_same_schema(looper, sdk_pool_handle,
                                  sdk_wallet_trust_anchor):
    sdk_write_schema_and_check(looper, sdk_pool_handle,
                               sdk_wallet_trust_anchor,
                               ["attrib1", "attrib2", "attrib3"], "business",
                               "1.8")

    with pytest.raises(RequestRejectedException) as ex_info:
        resp = sdk_write_schema_and_check(looper, sdk_pool_handle,
                                          sdk_wallet_trust_anchor,
                                          ["attrib1", "attrib2", "attrib3"],
                                          "business", "1.8")
        validate_write_reply(resp)
    ex_info.match(
        "can have one and only one SCHEMA with name business and version 1.8")
Exemplo n.º 8
0
    def run(self):
        # Step 1. Check default auth rule
        sdk_write_schema_and_check(self.looper, self.sdk_pool_handle, self.trustee_wallet, ["attrib1"], name='schema1',
                                   version='1.0')
        with pytest.raises(RequestRejectedException):
            sdk_write_schema_and_check(self.looper, self.sdk_pool_handle, self.new_default_wallet, ["attrib1"], name='schema2',
                                       version='1.0')

        # Step 2. Change auth rule
        self.send_and_check(self.changed_auth_rule, wallet=self.trustee_wallet)

        # Step 3. Check, that we cannot send schema the old way
        with pytest.raises(RequestRejectedException):
            sdk_write_schema_and_check(self.looper, self.sdk_pool_handle, self.trustee_wallet, ["attrib1"],
                                       name='schema3', version='1.0')

        # Step 4. Check, that new auth rule is used
        sdk_write_schema_and_check(self.looper, self.sdk_pool_handle, self.new_default_wallet, ["attrib1"], name='schema4',
                                   version='1.0')

        # Step 5. Return default auth rule
        self.send_and_check(self.default_auth_rule, wallet=self.trustee_wallet)

        # Step 6. Check, that default auth rule works
        sdk_write_schema_and_check(self.looper, self.sdk_pool_handle, self.trustee_wallet, ["attrib1"], name='schema5',
                                   version='1.0')
        with pytest.raises(RequestRejectedException):
            sdk_write_schema_and_check(self.looper, self.sdk_pool_handle, self.new_default_wallet, ["attrib1"], name='schema6',
                                       version='1.0')