def addRemoteManager(self): if not os.getenv('PRODUCTION'): host1 = 'localhost' host2 = 'localhost' else: host1 = 'yadaproject.com' host2 = 'yadaproject.com' node1name = str(uuid4()) node2name = str(uuid4()) node1 = Node({}, {"name" : node1name}) node2 = Node({}, {"name" : node2name}) #we're trying to recreate the above test but with a remote manager #this is the code we need to make remote. nc1 = NodeCommunicator(node1) nc2 = NodeCommunicator(node2) #make the node hosted on server response = nc1.addManager("%s:8040" % host1) response = nc2.addManager("%s:8041" % host2) #we need to know about node 2 in the manager's friends list before we can request them. #we need another update from the manager before we can route a request to them, legally. nc1ServerFriend = Node(node1.get('data/friends')[0]) nc1.updateRelationship(nc1ServerFriend) self.assertEqual(nc1ServerFriend.get('data/identity/name'), "node 1") nc1.requestFriend("%s:8041" % host2) #request to be friends with the manager's other friend (node 2) response = nc1.routeRequestThroughNode(Node(node1.get('data/friends')[1]), json.loads(response[1])['public_key']) self.assertEqual(len(nc1.node.get('data/friends')), 3) #lets pull down our new friend request nc2.updateRelationship(Node(node2.get('data/friends')[0])) self.assertEqual(len(node2.get('data/friends')[0]['data']['routed_friend_requests']), 1) #get the request request = node2.get('data/friends')[0]['data']['routed_friend_requests'][0] #accept the friend request node2.addFriend(request) #now we need to push the identity back because we just added a friend response = nc1.syncManager() response = nc2.syncManager() #now lets try to sync with the new friend, should automatically go to their manager nc2.updateRelationship(Node(node2.get('data/friends')[1])) response = nc1.syncManager() #now we verify that we can pull down the information from the new friend self.assertEqual(Node(node1.get('data/friends')[2]).get('data/identity/name'), node2name)
def Messaging(self): if os.getenv('PRODUCTION'): host1 = 'localhost:8040' else: host1 = 'yadaproject.com:8040' node1name = str(uuid4()) node1 = Node({}, {"name": node1name}) nc1 = NodeCommunicator(node1) nc1.requestFriend(host1) uuidSubject = str(uuid4()) nc1.sendMessage(nc1.node.getFriendPublicKeysArray(), uuidSubject, "message") import urllib2 json = urllib2.urlopen("http://" + host1).read() self.assertTrue(uuidSubject in json)
def Messaging(self): if os.getenv('PRODUCTION'): host1 = 'localhost:8040' else: host1 = 'yadaproject.com:8040' node1name = str(uuid4()) node1 = Node({}, {"name" : node1name}) nc1 = NodeCommunicator(node1) nc1.requestFriend(host1) uuidSubject = str(uuid4()) nc1.sendMessage(nc1.node.getFriendPublicKeysArray(), uuidSubject, "message") import urllib2 json = urllib2.urlopen("http://" + host1).read() self.assertTrue(uuidSubject in json)
def addRemoteManager(self): if not os.getenv('PRODUCTION'): host1 = 'localhost' host2 = 'localhost' else: host1 = 'yadaproject.com' host2 = 'yadaproject.com' node1name = str(uuid4()) node2name = str(uuid4()) node1 = Node({}, {"name": node1name}) node2 = Node({}, {"name": node2name}) #we're trying to recreate the above test but with a remote manager #this is the code we need to make remote. nc1 = NodeCommunicator(node1) nc2 = NodeCommunicator(node2) #make the node hosted on server response = nc1.addManager("%s:8040" % host1) response = nc2.addManager("%s:8041" % host2) #we need to know about node 2 in the manager's friends list before we can request them. #we need another update from the manager before we can route a request to them, legally. nc1ServerFriend = Node(node1.get('data/friends')[0]) nc1.updateRelationship(nc1ServerFriend) self.assertEqual(nc1ServerFriend.get('data/identity/name'), "node 1") nc1.requestFriend("%s:8041" % host2) #request to be friends with the manager's other friend (node 2) response = nc1.routeRequestThroughNode( Node(node1.get('data/friends')[1]), json.loads(response[1])['public_key']) self.assertEqual(len(nc1.node.get('data/friends')), 3) #lets pull down our new friend request nc2.updateRelationship(Node(node2.get('data/friends')[0])) self.assertEqual( len( node2.get('data/friends')[0]['data'] ['routed_friend_requests']), 1) #get the request request = node2.get( 'data/friends')[0]['data']['routed_friend_requests'][0] #accept the friend request node2.addFriend(request) #now we need to push the identity back because we just added a friend response = nc1.syncManager() response = nc2.syncManager() #now lets try to sync with the new friend, should automatically go to their manager nc2.updateRelationship(Node(node2.get('data/friends')[1])) response = nc1.syncManager() #now we verify that we can pull down the information from the new friend self.assertEqual( Node(node1.get('data/friends')[2]).get('data/identity/name'), node2name)