subdomain registrar interface now matches the interface for domain registration requests

This commit is contained in:
Aaron Blankstein
2017-08-02 16:10:01 -04:00
parent af0f3c9ad5
commit c97dddb4f8
2 changed files with 25 additions and 25 deletions

View File

@@ -27,6 +27,7 @@ import json
import sys
import os, subprocess
import blockstack_client
import blockstack_zones
import keylib
import requests
from blockstack_integration_tests.scenarios import testlib
@@ -107,14 +108,22 @@ core_auth_token = False
time.sleep(SLEEP_TIME)
baz_sk = keylib.ECPrivateKey()
uri_rec = (blockstack_client.zonefile.url_to_uri_record("file:///tmp/baz.profile.json"))
uri_rec = blockstack_client.zonefile.url_to_uri_record("file:///tmp/baz.profile.json")
owner_address = baz_sk.public_key().address()
zonefile_obj = {
'$origin' : "bar",
'$ttl' : 3600,
'uri' : [uri_rec]
}
zonefile_str = blockstack_zones.make_zone_file(zonefile_obj)
requests.post("http://localhost:7103/register",
data = json.dumps({"subdomain": "bar",
"owner" : owner_address,
"uris" : [uri_rec]}))
data = json.dumps({"name": "bar",
"min_confs" : 0,
"owner_address" : owner_address,
"zonefile" : zonefile_str}))
profile_raw = {"bar" : {
"@type" : "Person",

View File

@@ -211,44 +211,35 @@ def parse_subdomain_request(input_str):
schema = {
'type' : 'object',
'properties' : {
'subdomain' : {
'name' : {
'type': 'string',
'pattern': config.SUBDOMAIN_NAME_PATTERN
},
'owner' : {
'owner_address' : {
'type': 'string',
'pattern': schemas.OP_ADDRESS_PATTERN
},
'uris' : {
'type': 'array',
'items': schemas.URI_RECORD_SCHEMA
},
'zonefile_str' : {
'zonefile' : {
'type' : 'string',
'maxLength' : blockstack_constants.RPC_MAX_ZONEFILE_LEN
}
}
},
'required':[
'name', 'owner_address', 'zonefile'
],
'additionalProperties' : True
}
request = json.loads(input_str)
jsonschema.validate(request, schema)
zonefile_str = None
if 'zonefile_str' in request:
zonefile_str = request['zonefile_str']
elif 'uris' in request:
zonefile_dict = {
'$origin' : request['subdomain'],
'$ttl' : 3600,
'uri' : request['uris']
}
zonefile_str = blockstack_zones.make_zone_file(zonefile_dict)
zonefile_str = str(request['zonefile'])
if zonefile_str is None:
raise Exception("Request lacked either a zonefile_str or an uris entry")
owner_entry = str(request['owner'])
owner_entry = str(request['owner_address'])
return subdomains.Subdomain(
request['subdomain'], owner_entry,
request['name'], owner_entry,
n=0, zonefile_str = zonefile_str)
def run_registrar(domain_name):