mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-04-29 12:15:22 +08:00
subdomain registrar interface now matches the interface for domain registration requests
This commit is contained in:
@@ -27,6 +27,7 @@ import json
|
|||||||
import sys
|
import sys
|
||||||
import os, subprocess
|
import os, subprocess
|
||||||
import blockstack_client
|
import blockstack_client
|
||||||
|
import blockstack_zones
|
||||||
import keylib
|
import keylib
|
||||||
import requests
|
import requests
|
||||||
from blockstack_integration_tests.scenarios import testlib
|
from blockstack_integration_tests.scenarios import testlib
|
||||||
@@ -107,14 +108,22 @@ core_auth_token = False
|
|||||||
time.sleep(SLEEP_TIME)
|
time.sleep(SLEEP_TIME)
|
||||||
|
|
||||||
baz_sk = keylib.ECPrivateKey()
|
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()
|
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",
|
requests.post("http://localhost:7103/register",
|
||||||
data = json.dumps({"subdomain": "bar",
|
data = json.dumps({"name": "bar",
|
||||||
"owner" : owner_address,
|
"min_confs" : 0,
|
||||||
"uris" : [uri_rec]}))
|
"owner_address" : owner_address,
|
||||||
|
"zonefile" : zonefile_str}))
|
||||||
|
|
||||||
profile_raw = {"bar" : {
|
profile_raw = {"bar" : {
|
||||||
"@type" : "Person",
|
"@type" : "Person",
|
||||||
|
|||||||
@@ -211,44 +211,35 @@ def parse_subdomain_request(input_str):
|
|||||||
schema = {
|
schema = {
|
||||||
'type' : 'object',
|
'type' : 'object',
|
||||||
'properties' : {
|
'properties' : {
|
||||||
'subdomain' : {
|
'name' : {
|
||||||
'type': 'string',
|
'type': 'string',
|
||||||
'pattern': config.SUBDOMAIN_NAME_PATTERN
|
'pattern': config.SUBDOMAIN_NAME_PATTERN
|
||||||
},
|
},
|
||||||
'owner' : {
|
'owner_address' : {
|
||||||
'type': 'string',
|
'type': 'string',
|
||||||
'pattern': schemas.OP_ADDRESS_PATTERN
|
'pattern': schemas.OP_ADDRESS_PATTERN
|
||||||
},
|
},
|
||||||
'uris' : {
|
'zonefile' : {
|
||||||
'type': 'array',
|
|
||||||
'items': schemas.URI_RECORD_SCHEMA
|
|
||||||
},
|
|
||||||
'zonefile_str' : {
|
|
||||||
'type' : 'string',
|
'type' : 'string',
|
||||||
'maxLength' : blockstack_constants.RPC_MAX_ZONEFILE_LEN
|
'maxLength' : blockstack_constants.RPC_MAX_ZONEFILE_LEN
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
'required':[
|
||||||
|
'name', 'owner_address', 'zonefile'
|
||||||
|
],
|
||||||
|
'additionalProperties' : True
|
||||||
}
|
}
|
||||||
request = json.loads(input_str)
|
request = json.loads(input_str)
|
||||||
jsonschema.validate(request, schema)
|
jsonschema.validate(request, schema)
|
||||||
|
|
||||||
zonefile_str = None
|
zonefile_str = str(request['zonefile'])
|
||||||
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)
|
|
||||||
if zonefile_str is None:
|
if zonefile_str is None:
|
||||||
raise Exception("Request lacked either a zonefile_str or an uris entry")
|
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(
|
return subdomains.Subdomain(
|
||||||
request['subdomain'], owner_entry,
|
request['name'], owner_entry,
|
||||||
n=0, zonefile_str = zonefile_str)
|
n=0, zonefile_str = zonefile_str)
|
||||||
|
|
||||||
def run_registrar(domain_name):
|
def run_registrar(domain_name):
|
||||||
|
|||||||
Reference in New Issue
Block a user