mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-04-23 11:27:38 +08:00
This reverts us *all* the way back to 523cf405d7 -- this removes all changes to support the token file from this branch.
Revert "added example request and response for PUT /v1/wallet/keys/owner to api docs" This reverts commitd52ee4b31e. Revert "cutting down on the verbosity of logging outputs -- registrar now only prints 1 line on wakeups. storage drivers are concatenated into 1 line" This reverts commit87e3e7ab0d. Revert "adding dropbox as a default storage driver to load, and switched default 'required' drivers to 'disk,dropbox'" This reverts commit9471b0a20a. Revert "adding test case for issue 483, which *also* required fixing the app session schema to handle empty string methods a little bit more gracefully" This reverts commit32efc99d62. Revert "bugfix for the address reencoding in get_zonefile -- checks to see if the address is an address before trying to reencode" This reverts commit1488013b93. Revert "Merge branch 'rc-0.14.3' of github.com:blockstack/blockstack-core into rc-0.14.3" This reverts commitf75ab67960, reversing changes made tofe863bcd3c. Revert "don't create the metadata dir" This reverts commitfe863bcd3c. Revert "make all metadata directories inside the critical section" This reverts commite66236abd2. Revert "don't cast 'None' to string by accident" This reverts commitc6250d5349. Revert "force string" This reverts commite72d43d0be. Revert "add unbound proxy variable" This reverts commit7f1f7e9731. Revert "return raw zonefile" This reverts commit51e858428d. Revert "force string" This reverts commit1ce371644f. Revert "force string" This reverts commit5353cb1015. Revert "require virtualchain rc-0.14.3 and jsontokens-py 0.0.4" This reverts commit346f042db7. Revert "Merge branch 'rc-0.14.3' of https://github.com/blockstack/blockstack-core into rc-0.14.3" This reverts commit1fa1de3e54, reversing changes made to523cf405d7.
This commit is contained in:
@@ -169,13 +169,6 @@ class AuthInternal(APITestCase):
|
||||
data = self.get_request(url, headers = auth_header, status_code=200)
|
||||
self.assertIn('token', data)
|
||||
|
||||
def test_auth_new_token_no_username_issue483(self):
|
||||
auth_header = get_auth_header()
|
||||
test_string = "eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NksifQ.eyJ2ZXJzaW9uIjoxLCJibG9ja2NoYWluX2lkIjpudWxsLCJhcHBfcHJpdmF0ZV9rZXkiOiIxNDYwYWIyY2RjZmE1NDQwNzc5YWYwZDA0NWIzZTFlMjE5MjY4OGRjZTA5NDk4YWMyNDBkMTdjNzA2YWRiOThkIiwiYXBwX2RvbWFpbiI6Imh0dHA6Ly9sb2NhbGhvc3Q6NTAwMCIsIm1ldGhvZHMiOlsiIl0sImFwcF9wdWJsaWNfa2V5cyI6W3sicHVibGljX2tleSI6IjAzYTJhZmYyODhlYjI1NzVjZjE3ZTBjODc0NDZlNWExMDdmOTFkZjMzMjk5MjNkNDNmMDhmYTFmNzdlZDE0MTNmMCIsImRldmljZV9pZCI6IjAifV0sImRldmljZV9pZCI6IjAifQ.-uT-lOrvQDBZJWdg8p53LmEYBw1C8dVyGSAn96nR49MGSlNXP0vD7JsasjI6cbn9JSqGPFq1EpPLaHACkmyMcQ"
|
||||
url = "/v1/auth?authRequest={}".format(test_string)
|
||||
data = self.get_request(url, headers = auth_header, status_code=200)
|
||||
self.assertIn('token', data)
|
||||
|
||||
class UsersInternal(APITestCase):
|
||||
def test_get_users(self):
|
||||
user = "muneeb.id"
|
||||
|
||||
@@ -59,15 +59,8 @@ def scenario( wallets, **kw ):
|
||||
|
||||
testlib.blockstack_name_register( "demo.id", wallets[2].privkey, wallets[3].addr )
|
||||
testlib.next_block( **kw )
|
||||
|
||||
# add a token file
|
||||
res = testlib.migrate_profile( "demo.id", wallet_keys=wallet )
|
||||
if 'error' in res:
|
||||
res['test'] = 'Failed to initialize demo.id profile'
|
||||
print json.dumps(res, indent=4, sort_keys=True)
|
||||
return False
|
||||
|
||||
testlib.next_block( **kw )
|
||||
|
||||
|
||||
|
||||
def check( state_engine ):
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ def scenario( wallets, **kw ):
|
||||
|
||||
# sign in and make a token
|
||||
datastore_pk = keylib.ECPrivateKey(wallets[-1].privkey).to_hex()
|
||||
res = testlib.blockstack_cli_app_signin("foo.test", datastore_pk, 'foo-app.com.1', ['store_read', 'store_write', 'store_admin'])
|
||||
res = testlib.blockstack_cli_app_signin("foo.test", datastore_pk, 'foo-app.com', ['store_read', 'store_write', 'store_admin'])
|
||||
if 'error' in res:
|
||||
print json.dumps(res, indent=4, sort_keys=True)
|
||||
error = True
|
||||
|
||||
@@ -93,7 +93,7 @@ def scenario( wallets, **kw ):
|
||||
|
||||
# sign in and make a token
|
||||
datastore_pk = keylib.ECPrivateKey(wallets[-1].privkey).to_hex()
|
||||
res = testlib.blockstack_cli_app_signin("foo.test", datastore_pk, 'foo-app.com.1', ['store_read', 'store_write', 'store_admin'])
|
||||
res = testlib.blockstack_cli_app_signin("foo.test", datastore_pk, 'foo-app.com', ['store_read', 'store_write', 'store_admin'])
|
||||
if 'error' in res:
|
||||
print json.dumps(res, indent=4, sort_keys=True)
|
||||
error = True
|
||||
|
||||
@@ -96,7 +96,7 @@ def scenario( wallets, **kw ):
|
||||
|
||||
# sign in and make a token
|
||||
datastore_pk = keylib.ECPrivateKey(wallets[-1].privkey).to_hex()
|
||||
res = testlib.blockstack_cli_app_signin("foo.test", datastore_pk, 'foo-app.com.1', ['store_read', 'store_write', 'store_admin'])
|
||||
res = testlib.blockstack_cli_app_signin("foo.test", datastore_pk, 'foo-app.com', ['store_read', 'store_write', 'store_admin'])
|
||||
if 'error' in res:
|
||||
print json.dumps(res, indent=4, sort_keys=True)
|
||||
error = True
|
||||
|
||||
@@ -96,7 +96,7 @@ def scenario( wallets, **kw ):
|
||||
|
||||
# sign in and make a token
|
||||
datastore_pk = keylib.ECPrivateKey(wallets[-1].privkey).to_hex()
|
||||
res = testlib.blockstack_cli_app_signin("foo.test", datastore_pk, 'foo-app.com.1', ['store_read', 'store_write', 'store_admin'])
|
||||
res = testlib.blockstack_cli_app_signin("foo.test", datastore_pk, 'foo-app.com', ['store_read', 'store_write', 'store_admin'])
|
||||
if 'error' in res:
|
||||
print json.dumps(res, indent=4, sort_keys=True)
|
||||
error = True
|
||||
@@ -133,8 +133,6 @@ def scenario( wallets, **kw ):
|
||||
if 'error' not in res:
|
||||
print 'accidentally succeeded to mkdir {}: {}'.format(dpath, res)
|
||||
return False
|
||||
|
||||
# clear inode cache
|
||||
|
||||
# stat directories (should all fail locally due to ENOENT, since the parent directory will not have been updated)
|
||||
for dpath in ['/dir1/dir3/dir4', '/dir1/dir3', '/dir2', '/dir1']:
|
||||
@@ -345,22 +343,16 @@ def scenario( wallets, **kw ):
|
||||
print 'accidentally got {}: {}'.format(dpath, res)
|
||||
return False
|
||||
|
||||
# if res['errno'] != errno.EREMOTEIO:
|
||||
if res['errno'] != errno.ENOENT: # ENOENT since the latest data is in disk, or cache
|
||||
if res['errno'] != errno.EREMOTEIO:
|
||||
print 'wrong errno: {}'.format(res)
|
||||
return False
|
||||
|
||||
# stat files (should fail)
|
||||
# stat files (should still work)
|
||||
for dpath in ['/file1', '/file2', '/dir1/file3', '/dir1/dir3/file4', '/dir1/dir3/dir4/file5']:
|
||||
print 'stat {} (should fail)'.format(dpath)
|
||||
print 'stat {} (should still work)'.format(dpath)
|
||||
res = testlib.blockstack_cli_datastore_stat( 'foo.test', datastore_id, dpath, ses )
|
||||
if 'error' not in res:
|
||||
print 'accidentally got {}: {}'.format(dpath, res)
|
||||
return False
|
||||
|
||||
# if res['errno'] != errno.EREMOTEIO:
|
||||
if res['errno'] != errno.ENOENT: # ENOENT since the latest data is in disk, or cache
|
||||
print 'wrong errno: {}'.format(res)
|
||||
if 'error' in res:
|
||||
print 'failed to stat {}: {}'.format(path, res)
|
||||
return False
|
||||
|
||||
# restore test driver
|
||||
@@ -369,19 +361,6 @@ def scenario( wallets, **kw ):
|
||||
print 'failed to setenv: {}'.format(res)
|
||||
return False
|
||||
|
||||
# stat files (should fail)
|
||||
for dpath in ['/file1', '/file2', '/dir1/file3', '/dir1/dir3/file4', '/dir1/dir3/dir4/file5']:
|
||||
print 'stat {} (should fail)'.format(dpath)
|
||||
res = testlib.blockstack_cli_datastore_stat( 'foo.test', datastore_id, dpath, ses )
|
||||
if 'error' not in res:
|
||||
print 'accidentally got {}: {}'.format(dpath, res)
|
||||
return False
|
||||
|
||||
# if res['errno'] != errno.EREMOTEIO:
|
||||
if res['errno'] != errno.ENOENT: # ENOENT since the latest data is in disk, or cache
|
||||
print 'wrong errno: {}'.format(res)
|
||||
return False
|
||||
'''
|
||||
# stat files (should still work)
|
||||
for dpath in ['/file1', '/file2', '/dir1/file3', '/dir1/dir3/file4', '/dir1/dir3/dir4/file5']:
|
||||
print 'stat {}'.format(dpath)
|
||||
@@ -389,26 +368,14 @@ def scenario( wallets, **kw ):
|
||||
if 'error' in res:
|
||||
print 'failed to stat {}: {}'.format(path, res)
|
||||
return False
|
||||
'''
|
||||
|
||||
# remove files (should fail)
|
||||
# remove files (should work now)
|
||||
for dpath in ['/file1', '/file2', '/dir1/file3', '/dir1/dir3/file4', '/dir1/dir3/dir4/file5']:
|
||||
print 'deletefile {}'.format(dpath)
|
||||
res = testlib.blockstack_cli_datastore_deletefile( 'foo.test', datastore_pk, dpath, ses )
|
||||
if 'error' not in res:
|
||||
print 'accidentally succeeded to delete {}: {}'.format(dpath, res)
|
||||
return False
|
||||
|
||||
# if res['errno'] != errno.EREMOTEIO:
|
||||
if res['errno'] != errno.ENOENT: # ENOENT since the latest data is in disk, or cache
|
||||
print 'wrong errno: {}'.format(res)
|
||||
return False
|
||||
|
||||
'''
|
||||
if 'error' in res:
|
||||
print 'failed to deletefile {}: {}'.format(dpath, res)
|
||||
return False
|
||||
'''
|
||||
|
||||
# put file data (should succeed on both 'disk' and 'test')
|
||||
for dpath in ['/file1', '/file2', '/dir1/file3', '/dir1/dir3/file4', '/dir1/dir3/dir4/file5']:
|
||||
@@ -585,9 +552,8 @@ def scenario( wallets, **kw ):
|
||||
return False
|
||||
|
||||
if dpath not in ['/dir1/dir3/dir4', '/dir2']:
|
||||
#if res.get('errno') != errno.ENOTEMPTY:
|
||||
if res.get('errno') != errno.EREMOTEIO:
|
||||
print 'wrong errno for deleting {}: expected EREMOTEIO'.format(res)
|
||||
if res.get('errno') != errno.ENOTEMPTY:
|
||||
print 'wrong errno for deleting {}'.format(res)
|
||||
return False
|
||||
|
||||
# list directories (should fail for /dir1/dir3/dir4 and /dir2 since its idata got deleted, but it should still work for everyone else)
|
||||
@@ -598,11 +564,10 @@ def scenario( wallets, **kw ):
|
||||
print 'accidentally succeeded to list {}: {}'.format(dpath, res)
|
||||
return False
|
||||
|
||||
if res['errno'] != errno.ENOENT:
|
||||
if res['errno'] != errno.EREMOTEIO:
|
||||
print 'wrong errno: {}'.format(res)
|
||||
return False
|
||||
|
||||
'''
|
||||
# these should still work
|
||||
for dpath, expected in [('/', ['dir1', 'dir2']), ('/dir1', ['dir3']), ('/dir1/dir3', ['dir4'])]:
|
||||
print 'listdir {} (should still work)'.format(dpath)
|
||||
@@ -619,7 +584,6 @@ def scenario( wallets, **kw ):
|
||||
if not res['children'].has_key(child):
|
||||
print 'invalid directory: missing {} in {}'.format(child, res)
|
||||
return False
|
||||
'''
|
||||
|
||||
# restore service
|
||||
res = testlib.blockstack_test_setenv('BLOCKSTACK_INTEGRATION_TEST_STORAGE_FAILURE', '0')
|
||||
@@ -627,7 +591,6 @@ def scenario( wallets, **kw ):
|
||||
print 'failed to setenv: {}'.format(res)
|
||||
return False
|
||||
|
||||
'''
|
||||
# remove directories (should succeed)
|
||||
for dpath in ['/dir1/dir3/dir4', '/dir1/dir3', '/dir2', '/dir1']:
|
||||
print 'rmdir {}'.format(dpath)
|
||||
@@ -635,7 +598,6 @@ def scenario( wallets, **kw ):
|
||||
if 'error' in res:
|
||||
print 'failed to rmdir {}: {}'.format(dpath, res['error'])
|
||||
return False
|
||||
'''
|
||||
|
||||
# stat directories (should all fail)
|
||||
for dpath in ['/dir1/dir3/dir4', '/dir1/dir3', '/dir2', '/dir1']:
|
||||
@@ -700,13 +662,11 @@ def scenario( wallets, **kw ):
|
||||
print json.dumps(res)
|
||||
return False
|
||||
|
||||
'''
|
||||
# no more data in test-disk driver
|
||||
names = os.listdir("/tmp/blockstack-integration-test-storage/mutable")
|
||||
if names != ['foo.test']:
|
||||
print 'improper cleanup on test'
|
||||
return False
|
||||
'''
|
||||
|
||||
# due to our failed mkdir of /dir1 and /dir2, these
|
||||
# will have leaked. Expect 5 entries (including foo.test):
|
||||
|
||||
@@ -116,7 +116,7 @@ def activate_account(blockchain_id, datastore_pk):
|
||||
return False
|
||||
|
||||
# sign in and make a token with the given blockchain ID (whose wallet must be currently set)
|
||||
res = testlib.blockstack_cli_app_signin(blockchain_id, datastore_pk, 'app.com.1', ['store_read', 'store_write', 'store_admin'])
|
||||
res = testlib.blockstack_cli_app_signin(blockchain_id, datastore_pk, 'app.com', ['store_read', 'store_write', 'store_admin'])
|
||||
if 'error' in res:
|
||||
print json.dumps(res, indent=4, sort_keys=True)
|
||||
return False
|
||||
@@ -137,7 +137,7 @@ def core_signin(datastore_pk, blockchain_id):
|
||||
global sessions
|
||||
|
||||
# sign in and make a token with the given blockchain ID (whose wallet must be currently set)
|
||||
res = testlib.blockstack_cli_app_signin(blockchain_id, datastore_pk, 'app.com.1', ['store_read', 'store_write', 'store_admin'])
|
||||
res = testlib.blockstack_cli_app_signin(blockchain_id, datastore_pk, 'app.com', ['store_read', 'store_write', 'store_admin'])
|
||||
if 'error' in res:
|
||||
print json.dumps(res, indent=4, sort_keys=True)
|
||||
return False
|
||||
@@ -167,26 +167,8 @@ def target_datastore(blockchain_id):
|
||||
if 'error' in res:
|
||||
print json.dumps(res, indent=4, sort_keys=True)
|
||||
return False
|
||||
|
||||
old_root = os.environ.get('TEST_BLOCKSTACK_TEST_DISK_ROOT', None)
|
||||
old_blockchain_id = None
|
||||
|
||||
if old_root:
|
||||
old_root_parts = old_root.split('-')
|
||||
if old_root_parts[-1].endswith('.test'):
|
||||
old_blockchain_id = old_root_parts[-1]
|
||||
|
||||
new_root = '/tmp/blockstack-integration-test-storage{}'.format(blockchain_id)
|
||||
os.environ['TEST_BLOCKSTACK_TEST_DISK_ROOT'] = new_root
|
||||
|
||||
if old_blockchain_id and os.path.exists(new_root + '/index'):
|
||||
# sanity check: look for weird race conditions
|
||||
rc = os.system("fgrep '{}' -r '{}/index' >/dev/null".format(old_blockchain_id, new_root))
|
||||
if rc != 0:
|
||||
print '\n\nBUG: blockchain ID {} found in {}/index'.format(old_blockchain_id, new_root)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
os.environ['TEST_BLOCKSTACK_TEST_DISK_ROOT'] = '/tmp/blockstack-integration-test-storage{}'.format(blockchain_id)
|
||||
|
||||
|
||||
def setup_datastore(datastore_pk, blockchain_id, write_iteration):
|
||||
@@ -560,9 +542,7 @@ def scenario( wallets, **kw ):
|
||||
print 'failed to start API for foo.test: {}'.format(res)
|
||||
return False
|
||||
|
||||
rc = target_datastore('foo.test')
|
||||
if not rc:
|
||||
return False
|
||||
target_datastore('foo.test')
|
||||
|
||||
# instantiate foo.test's test driver
|
||||
res = testlib.blockstack_REST_call('POST', '/v1/node/drivers/storage/test?index=1&force=1', None, api_pass='blockstack_integration_test_api_password')
|
||||
@@ -585,9 +565,7 @@ def scenario( wallets, **kw ):
|
||||
|
||||
# link test account for bar.test
|
||||
# BUT! make sure we store the profile for bar.test into foo.test's and bar.test's storage directories!
|
||||
rc = target_datastore('bar.test')
|
||||
if not rc:
|
||||
return False
|
||||
target_datastore('bar.test')
|
||||
|
||||
# instantiate bar.test's test driver
|
||||
res = testlib.blockstack_REST_call('POST', '/v1/node/drivers/storage/test?index=1&force=1', None, api_pass='blockstack_integration_test_api_password')
|
||||
@@ -641,9 +619,7 @@ def scenario( wallets, **kw ):
|
||||
# make *absolutely certain* that the test driver does not load data from
|
||||
# foo.test's or bar.test's storage directories. We want to verify that we can look up
|
||||
# the index manifest URLs from the profile
|
||||
rc = target_datastore(None)
|
||||
if not rc:
|
||||
return False
|
||||
target_datastore(None)
|
||||
|
||||
print "\n\nbar.test tries to read foo.test's datastore {}\n\n".format(foo_datastore_id)
|
||||
res = read_datastore(foo_datastore_id, "foo.test", 1)
|
||||
@@ -666,9 +642,7 @@ def scenario( wallets, **kw ):
|
||||
# make *absolutely certain* that the test driver does not load data from
|
||||
# foo.test's or bar.test's storage directories. We want to verify that we can look up
|
||||
# the index manifest URLs from the profile
|
||||
rc = target_datastore(None)
|
||||
if not rc:
|
||||
return False
|
||||
target_datastore(None)
|
||||
|
||||
# try to read all of bar.test's files
|
||||
print "\n\nfoo.test tries to read bar.test's datastore {}\n\n".format(bar_datastore_id)
|
||||
@@ -678,9 +652,7 @@ def scenario( wallets, **kw ):
|
||||
return False
|
||||
|
||||
# re-target foo.test's datastore
|
||||
rc = target_datastore('foo.test')
|
||||
if not rc:
|
||||
return False
|
||||
target_datastore('foo.test')
|
||||
|
||||
# have foo.test write new files
|
||||
print '\n\nupdate foo.test datastore\n\n'
|
||||
@@ -698,9 +670,7 @@ def scenario( wallets, **kw ):
|
||||
# make *absolutely certain* that the test driver does not load data from
|
||||
# foo.test's or bar.test's storage directories. We want to verify that we can look up
|
||||
# the index manifest URLs from the profile
|
||||
rc = target_datastore(None)
|
||||
if not rc:
|
||||
return False
|
||||
target_datastore(None)
|
||||
|
||||
# get foo.test's new files
|
||||
res = read_datastore(foo_datastore_id, 'foo.test', 3)
|
||||
@@ -709,9 +679,7 @@ def scenario( wallets, **kw ):
|
||||
return False
|
||||
|
||||
# re-target bar.test's datastore
|
||||
rc = target_datastore('bar.test')
|
||||
if not rc:
|
||||
return False
|
||||
target_datastore('bar.test')
|
||||
|
||||
# have bar write some new files
|
||||
print '\n\nupdate bar.test datastore\n\n'
|
||||
@@ -742,9 +710,7 @@ def scenario( wallets, **kw ):
|
||||
# make *absolutely certain* that the test driver does not load data from
|
||||
# foo.test's or bar.test's storage directories. We want to verify that we can look up
|
||||
# the index manifest URLs from the profile
|
||||
rc = target_datastore(None)
|
||||
if not rc:
|
||||
return False
|
||||
target_datastore(None)
|
||||
|
||||
# verify that foo's files are gone
|
||||
res = check_datastore_files_absent(foo_datastore_id, 'foo.test')
|
||||
@@ -753,9 +719,7 @@ def scenario( wallets, **kw ):
|
||||
return False
|
||||
|
||||
# re-target bar.test's datastore
|
||||
rc = target_datastore('bar.test')
|
||||
if not rc:
|
||||
return False
|
||||
target_datastore('bar.test')
|
||||
|
||||
# clear bar.test's files
|
||||
print '\n\ndelete bar.test files\n\n'
|
||||
@@ -773,9 +737,7 @@ def scenario( wallets, **kw ):
|
||||
# make *absolutely certain* that the test driver does not load data from
|
||||
# foo.test's or bar.test's storage directories. We want to verify that we can look up
|
||||
# the index manifest URLs from the profile
|
||||
rc = target_datastore(None)
|
||||
if not rc:
|
||||
return False
|
||||
target_datastore(None)
|
||||
|
||||
# verify that bar's files are gone
|
||||
res = check_datastore_files_absent(bar_datastore_id, 'bar.test')
|
||||
@@ -784,9 +746,7 @@ def scenario( wallets, **kw ):
|
||||
return False
|
||||
|
||||
# re-target foo.test's datastore
|
||||
rc = target_datastore("foo.test")
|
||||
if not rc:
|
||||
return False
|
||||
target_datastore("foo.test")
|
||||
|
||||
# clear foo's directories
|
||||
res = clear_datastore_directories('foo.test', foo_datastore_pk)
|
||||
@@ -803,9 +763,7 @@ def scenario( wallets, **kw ):
|
||||
# make *absolutely certain* that the test driver does not load data from
|
||||
# foo.test's or bar.test's storage directories. We want to verify that we can look up
|
||||
# the index manifest URLs from the profile
|
||||
rc = target_datastore(None)
|
||||
if not rc:
|
||||
return False
|
||||
target_datastore(None)
|
||||
|
||||
# verify that foo's directories are gone
|
||||
res = check_datastore_directories_absent(foo_datastore_id, "foo.test")
|
||||
@@ -814,9 +772,7 @@ def scenario( wallets, **kw ):
|
||||
return False
|
||||
|
||||
# re-target bar.test's datastore
|
||||
rc = target_datastore('bar.test')
|
||||
if not rc:
|
||||
return False
|
||||
target_datastore('bar.test')
|
||||
|
||||
# clear bar's directories
|
||||
res = clear_datastore_directories('bar.test', bar_datastore_pk)
|
||||
@@ -833,9 +789,7 @@ def scenario( wallets, **kw ):
|
||||
# make *absolutely certain* that the test driver does not load data from
|
||||
# foo.test's or bar.test's storage directories. We want to verify that we can look up
|
||||
# the index manifest URLs from the profile
|
||||
rc = target_datastore(None)
|
||||
if not rc:
|
||||
return False
|
||||
target_datastore(None)
|
||||
|
||||
# verify that bar's directories are gone
|
||||
res = check_datastore_directories_absent(bar_datastore_id, "bar.test")
|
||||
|
||||
@@ -93,7 +93,7 @@ def scenario( wallets, **kw ):
|
||||
|
||||
# sign in and make a token
|
||||
datastore_pk = keylib.ECPrivateKey(wallets[-1].privkey).to_hex()
|
||||
res = testlib.blockstack_cli_app_signin("foo.test", datastore_pk, 'foo-app.com.1', ['store_read', 'store_write', 'store_admin'])
|
||||
res = testlib.blockstack_cli_app_signin("foo.test", datastore_pk, 'foo-app.com', ['store_read', 'store_write', 'store_admin'])
|
||||
if 'error' in res:
|
||||
print json.dumps(res, indent=4, sort_keys=True)
|
||||
error = True
|
||||
|
||||
@@ -95,7 +95,7 @@ def scenario( wallets, **kw ):
|
||||
|
||||
# sign in and make a token
|
||||
datastore_pk = keylib.ECPrivateKey(wallets[-1].privkey).to_hex()
|
||||
res = testlib.blockstack_cli_app_signin("foo.test", datastore_pk, 'foo-app.com.1', ['store_read', 'store_write', 'store_admin'])
|
||||
res = testlib.blockstack_cli_app_signin("foo.test", datastore_pk, 'foo-app.com', ['store_read', 'store_write', 'store_admin'])
|
||||
if 'error' in res:
|
||||
print json.dumps(res, indent=4, sort_keys=True)
|
||||
error = True
|
||||
|
||||
@@ -95,7 +95,7 @@ def scenario( wallets, **kw ):
|
||||
|
||||
# sign in and make a token
|
||||
datastore_pk = keylib.ECPrivateKey(wallets[-1].privkey).to_hex()
|
||||
res = testlib.blockstack_cli_app_signin("foo.test", datastore_pk, 'foo-app.com.1', ['store_read', 'store_write', 'store_admin'])
|
||||
res = testlib.blockstack_cli_app_signin("foo.test", datastore_pk, 'foo-app.com', ['store_read', 'store_write', 'store_admin'])
|
||||
if 'error' in res:
|
||||
print json.dumps(res, indent=4, sort_keys=True)
|
||||
error = True
|
||||
|
||||
@@ -1729,8 +1729,7 @@ def blockstack_cli_app_put_resource( blockchain_id, app_domain, res_path, res_fi
|
||||
|
||||
def blockstack_cli_app_signin( blockchain_id, app_privkey, app_domain, api_methods, device_ids=None, public_keys=None, config_path=None ):
|
||||
"""
|
||||
sign in and get a token.
|
||||
sign up if we need to.
|
||||
sign in and get a token
|
||||
"""
|
||||
if config_path is None:
|
||||
test_proxy = make_proxy(config_path=config_path)
|
||||
@@ -1744,21 +1743,16 @@ def blockstack_cli_app_signin( blockchain_id, app_privkey, app_domain, api_metho
|
||||
args.api_methods = ','.join(api_methods)
|
||||
args.privkey = app_privkey
|
||||
|
||||
res = cli_app_signin( args, config_path=config_path )
|
||||
if 'error' in res:
|
||||
if '`app_signup`' in res['error']:
|
||||
# need to sign up first
|
||||
res = cli_app_signup(args, config_path=config_path)
|
||||
if 'error' in res:
|
||||
return res
|
||||
|
||||
else:
|
||||
return res
|
||||
if device_ids is None and public_keys is None:
|
||||
device_ids = [blockstack_client.config.get_local_device_id()]
|
||||
public_keys = [keylib.ECPrivateKey(app_privkey).public_key().to_hex()]
|
||||
|
||||
# now sign in
|
||||
res = cli_app_signin(args, config_path=config_path)
|
||||
device_ids = ','.join(device_ids)
|
||||
public_keys = ','.join(public_keys)
|
||||
args.device_ids = device_ids
|
||||
args.public_keys = public_keys
|
||||
|
||||
return res
|
||||
return cli_app_signin( args, config_path=config_path )
|
||||
|
||||
|
||||
def blockstack_cli_create_datastore(blockchain_id, datastore_privkey, drivers, ses, device_ids=None, config_path=None):
|
||||
@@ -3057,11 +3051,11 @@ def put_test_data( relpath, data, **kw ):
|
||||
|
||||
def migrate_profile( name, proxy=None, wallet_keys=None, zonefile_has_data_key=True, config_path=None ):
|
||||
"""
|
||||
Migrate a user's profile from the legacy format to the token-file/zonefile format.
|
||||
Migrate a user's profile from the legacy format to the profile/zonefile format.
|
||||
Broadcast an update transaction with the zonefile hash.
|
||||
Replicate the zonefile and token file.
|
||||
Replicate the zonefile and profile.
|
||||
|
||||
Return {'status': True, 'zonefile': ..., 'profile': ..., 'token_file': ..., 'transaction_hash': ...} on success, if the profile was migrated
|
||||
Return {'status': True, 'zonefile': ..., 'profile': ..., 'transaction_hash': ...} on success, if the profile was migrated
|
||||
Return {'status': True} on success, if the profile is already migrated
|
||||
Return {'error': ...} on error
|
||||
"""
|
||||
@@ -3078,7 +3072,6 @@ def migrate_profile( name, proxy=None, wallet_keys=None, zonefile_has_data_key=T
|
||||
user_profile = None
|
||||
user_zonefile = None
|
||||
user_zonefile_txt = None
|
||||
new_token_file = None
|
||||
|
||||
res = blockstack_cli_lookup(name, config_path=config_path)
|
||||
if 'error' in res:
|
||||
@@ -3118,29 +3111,31 @@ def migrate_profile( name, proxy=None, wallet_keys=None, zonefile_has_data_key=T
|
||||
# not JSON
|
||||
user_zonefile = blockstack_zones.parse_zone_file(user_zonefile_txt)
|
||||
|
||||
# add public key, if absent
|
||||
if blockstack_client.user.user_zonefile_data_pubkey(user_zonefile) is None and zonefile_has_data_key:
|
||||
log.debug("Adding zone file public key")
|
||||
user_zonefile = blockstack_client.user.user_zonefile_set_data_pubkey(user_zonefile, keylib.ECPrivateKey(wallet_keys['data_privkey']).public_key().to_hex())
|
||||
|
||||
payment_privkey_info = blockstack_client.get_payment_privkey_info( wallet_keys=wallet_keys, config_path=proxy.conf['path'] )
|
||||
owner_privkey_info = blockstack_client.get_owner_privkey_info( wallet_keys=wallet_keys, config_path=proxy.conf['path'] )
|
||||
data_privkey_info = blockstack_client.get_data_privkey_info( user_zonefile, wallet_keys=wallet_keys, config_path=proxy.conf['path'] )
|
||||
|
||||
'''
|
||||
|
||||
assert data_privkey_info is not None
|
||||
assert 'error' not in data_privkey_info, str(data_privkey_info)
|
||||
assert virtualchain.is_singlesig(data_privkey_info)
|
||||
'''
|
||||
|
||||
res = blockstack_client.actions.migrate_profile_to_token_file(name, user_profile, owner_privkey_info, config_path=config_path)
|
||||
if 'error' in res:
|
||||
return {'error': 'Failed to create new token file'}
|
||||
|
||||
new_token_file = res['token_file']
|
||||
user_zonefile_hash = blockstack_client.hash_zonefile( user_zonefile )
|
||||
|
||||
# replicate the token file
|
||||
signing_key = blockstack_client.keys.get_signing_privkey(owner_privkey_info)
|
||||
rc = blockstack_client.token_file.token_file_put(name, new_token_file, signing_key, config_path=config_path)
|
||||
# replicate the profile
|
||||
# TODO: this is onename-specific
|
||||
|
||||
rc = blockstack_client.profile.put_profile(name, user_profile, blockchain_id=name,
|
||||
user_data_privkey=data_privkey_info, user_zonefile=user_zonefile,
|
||||
proxy=proxy, wallet_keys=wallet_keys )
|
||||
|
||||
if 'error' in rc:
|
||||
log.error("Failed to put token file: {}".format(rc['error']))
|
||||
return {'error': 'Failed to move legacy profile to token file and zonefile'}
|
||||
log.error("Failed to put profile: {}".format(rc['error']))
|
||||
return {'error': 'Failed to move legacy profile to profile zonefile'}
|
||||
|
||||
# do the update
|
||||
res = blockstack_client.do_update( name, user_zonefile_hash, owner_privkey_info, payment_privkey_info, proxy, proxy, config_path=proxy.config_path, proxy=proxy )
|
||||
@@ -3160,8 +3155,7 @@ def migrate_profile( name, proxy=None, wallet_keys=None, zonefile_has_data_key=T
|
||||
'transaction_hash': res['transaction_hash'],
|
||||
'zonefile': user_zonefile,
|
||||
'zonefile_txt': user_zonefile_txt,
|
||||
'profile': user_profile,
|
||||
'token_file': new_token_file,
|
||||
'profile': user_profile
|
||||
}
|
||||
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user