def test_created_related_actions_multiple_subscribers(self):

        collection_name = "sharing_collection"
        subscribers = [self.__subscriber_id, self.__second_subscriber]
        sharing_secret = self.__create_sharing_record(subscribers, collection_name)
        subscribers.append(self.__account_id)

        file = open("../test_resources/XooML.xml")
        manifest_action = UpdateSharedManifestAction(self.__account_id, collection_name, file)
        SharingActionFactory.create_related_sharing_actions(sharing_secret, manifest_action, callback=self.stop)
        sharing_action_list = self.wait()

        self.assertEqual(3, len(sharing_action_list))

        for sharing_action in sharing_action_list:
            user_id = sharing_action.get_user_id()
            self.assertTrue(user_id in subscribers)
            subscribers.remove(user_id)
            self.assertEqual(SharingEvent.UPDATE_MANIFEST, sharing_action.get_action_type())
        self.assertEqual(0, len(subscribers))

        # cleanup
        SharingController.remove_sharing_record_by_secret(sharing_secret, callback=self.stop)
        self.wait()
        for sharing_action in sharing_action_list:
            user_id = sharing_action.get_user_id()
            collection_name = sharing_action.get_collection_name()
            StorageServer.remove_collection(user_id, collection_name, callback=self.stop)
            self.wait()
Ejemplo n.º 2
0
    def test_remove_all_subscribers(self):

        collection_name = "shareable_collection"
        file = open("../test_resources/XooML.xml")
        StorageServer.add_collection(
            user_id=self.__account_id, collection_name=collection_name, callback=self.stop, file=file
        )
        response = self.wait()

        self.assertEqual(StorageResponse.OK, response)

        SharingController.create_sharing_record(self.__account_id, collection_name, callback=self.stop)
        sharing_secret = self.wait()

        SharingController.subscribe_to_sharing_space(self.__subscriber_id, sharing_secret, callback=self.stop)
        collection_name2 = self.wait(timeout=500)

        SharingController.remove_all_subscribers(sharing_secret, callback=self.stop)
        self.wait(timeout=10000)

        # busy wait for the results of remove all subscribers to become consistent
        try:
            self.wait(timeout=5)
        except Exception:
            pass

        SharingController.get_sharing_secret_from_subscriber_info(
            self.__account_id, collection_name, callback=self.stop
        )
        actual_sharing_secret = self.wait()
        self.assertTrue(actual_sharing_secret is None)
        SharingController.get_sharing_secret_from_subscriber_info("second_user", collection_name2, callback=self.stop)
        actual_sharing_secret = self.wait()
        self.assertTrue(actual_sharing_secret is None)
    def test_create_related_actions_update_thumbnail(self):

        collection_name = "sharing_collection"
        subscribers = [self.__subscriber_id]
        sharing_secret = self.__create_sharing_record(subscribers, collection_name)
        subscribers.append(self.__account_id)

        file = open("../test_resources/XooML.xml")
        thumbnail_action = UpdateSharedThumbnailAction(self.__account_id, collection_name, file)
        SharingActionFactory.create_related_sharing_actions(sharing_secret, thumbnail_action, callback=self.stop)
        sharing_action_list = self.wait()

        self.assertEqual(2, len(sharing_action_list))

        for sharing_action in sharing_action_list:
            user_id = sharing_action.get_user_id()
            thumbnail_file = sharing_action.get_associated_file()
            self.assertTrue(thumbnail_file is not None)
            self.assertTrue(user_id in subscribers)
            subscribers.remove(user_id)
            self.assertEqual(SharingEvent.UPDATE_THUMBNAIL, sharing_action.get_action_type())
        self.assertEqual(0, len(subscribers))

        # cleanup
        SharingController.remove_sharing_record_by_secret(sharing_secret, callback=self.stop)
        self.wait()
        for sharing_action in sharing_action_list:
            user_id = sharing_action.get_user_id()
            collection_name = sharing_action.get_collection_name()
            StorageServer.remove_collection(user_id, collection_name, callback=self.stop)
            self.wait()
Ejemplo n.º 4
0
    def test_get_sharing_space_info_existing(self):

        servers = ['a', 'b', 'c']
        Properties.sharing_space_servers = servers
        collection_name = str(uuid.uuid4())
        subscriber_list = [self.__subscriber_id, self.__second_subscriber_id]
        sharing_secret, subscribers_collections =\
        self.__create_sharing_record(subscriber_list, collection_name)
        load_balancer = SharingLoadBalancer.get_instance()
        load_balancer.get_sharing_space_info(sharing_secret, callback=self.stop)
        server_info = self.wait()
        server_adrs = server_info['server']
        self.assertTrue(server_adrs in servers)

        load_balancer.get_sharing_space_info(sharing_secret, callback=self.stop)
        second_server_info = self.wait()
        second_server_adrs = second_server_info['server']
        self.assertEqual(server_adrs, second_server_adrs)

        #cleanup
        SharingController.remove_sharing_record_by_secret(sharing_secret, callback =self.stop)
        self.wait()
        StorageServer.remove_collection(self.__account_id, collection_name,
            callback=self.stop)
        for subscriber_id in subscribers_collections:
            subscriber_collection = subscribers_collections[subscriber_id]
            StorageServer.remove_collection(subscriber_id, subscriber_collection,
                callback=self.stop)
            self.wait()
    def test_create_related_actions_update_note_img(self):

        collection_name = "sharing_collection"
        subscribers = [self.__subscriber_id]
        sharing_secret = self.__create_sharing_record(subscribers, collection_name)
        subscribers.append(self.__account_id)

        note_name = "lala_note"
        file = open("../test_resources/XooML.xml")
        note_img_action = UpdateSharedNoteImageAction(self.__account_id, collection_name, note_name, file)
        SharingActionFactory.create_related_sharing_actions(sharing_secret, note_img_action, callback=self.stop)
        sharing_action_list = self.wait()

        self.assertEqual(2, len(sharing_action_list))

        for sharing_action in sharing_action_list:
            user_id = sharing_action.get_user_id()
            actual_note_name = sharing_action.get_note_name()
            self.assertEqual(note_name, actual_note_name)
            self.assertTrue(user_id in subscribers)
            subscribers.remove(user_id)
            self.assertEqual(SharingEvent.UPDATE_NOTE_IMG, sharing_action.get_action_type())
        self.assertEqual(0, len(subscribers))

        # cleanup
        SharingController.remove_sharing_record_by_secret(sharing_secret, callback=self.stop)
        self.wait()
        for sharing_action in sharing_action_list:
            user_id = sharing_action.get_user_id()
            collection_name = sharing_action.get_collection_name()
            StorageServer.remove_collection(user_id, collection_name, callback=self.stop)
            self.wait()
Ejemplo n.º 6
0
    def test_get_sharing_space_server_existing(self):

        collection_name = str(uuid.uuid4())
        subscriber_list = [self.__subscriber_id, self.__second_subscriber_id]
        sharing_secret, subscribers_collections =\
        self.__create_sharing_record(subscriber_list, collection_name)

        joker = JokerHelper.get_instance()
        joker.get_sharing_space_server(sharing_secret, callback=self.stop)
        server_adrs1 = self.wait(timeout=10000)
        self.assertIn(server_adrs1, Properties.sharing_space_servers)
        print server_adrs1


        joker.get_sharing_space_server(sharing_secret, callback=self.stop)
        server_adrs2 = self.wait(timeout=10000)
        self.assertIn(server_adrs2, Properties.sharing_space_servers)
        self.assertEqual(server_adrs1, server_adrs2)
        print server_adrs2

        #cleanup
        SharingController.remove_sharing_record_by_secret(sharing_secret, callback =self.stop)
        self.wait()
        StorageServer.remove_collection(self.__account_id, collection_name,
            callback=self.stop)
        for subscriber_id in subscribers_collections:
            subscriber_collection = subscribers_collections[subscriber_id]
            StorageServer.remove_collection(subscriber_id, subscriber_collection,
                callback=self.stop)
            self.wait()
    def test_create_related_actions_delete_note(self):

        collection_name = "sharing_collection"
        subscribers = [self.__subscriber_id]
        sharing_secret = self.__create_sharing_record(subscribers, collection_name)
        subscribers.append(self.__account_id)

        note_name = "lala note"
        delete_action = DeleteSharedNoteAction(self.__account_id, collection_name, note_name)

        SharingActionFactory.create_related_sharing_actions(sharing_secret, delete_action, callback=self.stop)
        sharing_action_list = self.wait()

        self.assertEqual(2, len(sharing_action_list))

        for sharing_action in sharing_action_list:
            user_id = sharing_action.get_user_id()
            actual_note_name = sharing_action.get_note_name()
            note_file = sharing_action.get_associated_file()
            self.assertTrue(note_file is None)
            self.assertEqual(note_name, actual_note_name)
            self.assertTrue(user_id in subscribers)
            subscribers.remove(user_id)
            self.assertEqual(SharingEvent.DELETE_NOTE, sharing_action.get_action_type())
        self.assertEqual(0, len(subscribers))

        # cleanup
        SharingController.remove_sharing_record_by_secret(sharing_secret, callback=self.stop)
        self.wait()
        for sharing_action in sharing_action_list:
            user_id = sharing_action.get_user_id()
            collection_name = sharing_action.get_collection_name()
            StorageServer.remove_collection(user_id, collection_name, callback=self.stop)
            self.wait()
Ejemplo n.º 8
0
    def __create_sharing_record(self, subscriber_list, collection_name):

        #create collection
        file = open('../test_resources/XooML.xml')
        StorageServer.add_collection(user_id=self.__account_id,
            collection_name= collection_name, callback=self.stop, file= file)
        response = self.wait()
        self.assertEqual(StorageResponse.OK, response)

        #create sharing record
        SharingController.create_sharing_record(self.__account_id,
            collection_name, callback = self.stop)
        sharing_secret = self.wait(timeout=10000)
        self.assertTrue(sharing_secret is not None)

        subscribers = {}
        for subscriber_id in subscriber_list:
            #subscribe
            SharingController.subscribe_to_sharing_space(subscriber_id,
                sharing_secret, callback = self.stop)
            subscribers_collection_name  = self.wait()
            self.assertTrue(subscribers_collection_name is not None)
            subscribers[subscriber_id] = subscribers_collection_name

        return sharing_secret, subscribers
Ejemplo n.º 9
0
    def test_reshare_already_shared_collection(self):

        # create collection
        first_collection_name = "shareable_collection"
        file = open("../test_resources/XooML.xml")
        StorageServer.add_collection(
            user_id=self.__account_id, collection_name=first_collection_name, callback=self.stop, file=file
        )
        response = self.wait()
        self.assertEqual(StorageResponse.OK, response)

        # create sharing record
        SharingController.create_sharing_record(self.__account_id, first_collection_name, callback=self.stop)
        sharing_secret = self.wait()
        self.assertTrue(sharing_secret is not None)

        # duplicate create sharing record
        SharingController.create_sharing_record(self.__account_id, first_collection_name, callback=self.stop)
        new_sharing_secret = self.wait()
        self.assertEqual(sharing_secret, new_sharing_secret)

        # verify that only one sharing record was added
        SharingController.get_sharing_record_by_owner_info(self.__account_id, first_collection_name, callback=self.stop)
        sharing_record = self.wait()
        subscribers_list = sharing_record.get_subscribers()
        self.assertEqual(1, len(subscribers_list))

        # cleanup
        SharingController.remove_sharing_record_by_secret(sharing_secret, callback=self.stop)
        self.wait()
        StorageServer.remove_collection(self.__account_id, first_collection_name, callback=self.stop)
        self.wait()
Ejemplo n.º 10
0
    def test_delete_note(self):

        collection_name = str(uuid.uuid4())
        subscriber_list = [self.__subscriber_id]
        sharing_secret, subscribers_collections =\
        self.__create_sharing_record(subscriber_list, collection_name)


        joker = JokerHelper.get_instance()
        joker.get_sharing_space_server(sharing_secret, callback=self.stop)
        server_adrs = self.wait(timeout=10000)
        self.assertIn(server_adrs, Properties.sharing_space_servers)

        note_file = open('../test_resources/sharing_template1.xml')
        note_name = str(uuid.uuid4())
        joker.update_note(server_adrs, sharing_secret,
            self.__account_id, collection_name, note_name, note_file, callback=self.stop)
        result = self.wait(timeout=1000)
        self.assertEqual(StorageResponse.OK,result)

        #wait for a while
        self.__wait(10)

        #now delete
        joker.delete_note(server_adrs, sharing_secret, self.__account_id,
            collection_name, note_name, callback=self.stop)
        response = self.wait()
        self.assertEqual(StorageResponse.OK, response)

        #wait for a while
        self.__wait(10)

        #Now Try to retreive the note
        StorageServer.get_note_from_collection(self.__account_id,
            collection_name, note_name, callback=self.stop)
        response = self.wait()
        self.assertTrue(response is None)

        #cleanup
        SharingController.remove_sharing_record_by_secret(sharing_secret, callback =self.stop)
        self.wait()
        StorageServer.remove_collection(self.__account_id, collection_name,
            callback=self.stop)
        for subscriber_id in subscribers_collections:
            subscriber_collection = subscribers_collections[subscriber_id]
            StorageServer.remove_collection(subscriber_id, subscriber_collection,
                callback=self.stop)
            self.wait()
Ejemplo n.º 11
0
    def test_update_manifest(self):

        collection_name = str(uuid.uuid4())
        subscriber_list = [self.__subscriber_id]
        sharing_secret, subscribers_collections =\
        self.__create_sharing_record(subscriber_list, collection_name)


        joker = JokerHelper.get_instance()
        joker.get_sharing_space_server(sharing_secret, callback=self.stop)
        server_adrs = self.wait(timeout=10000)
        self.assertIn(server_adrs, Properties.sharing_space_servers)

        manifest_file = open('../test_resources/sharing_template1.xml')
        expected_manifest_body = manifest_file.read()
        joker.update_manifest(server_adrs, sharing_secret, self.__account_id,
            collection_name, manifest_file, callback=self.stop)
        response = self.wait(timeout=1000)
        self.assertEqual(StorageResponse.OK, response)

        #wait for a while
        self.__wait(10)

        #try to retrieve the file
        StorageServer.get_collection_manifest(self.__account_id, collection_name,
            callback=self.stop)
        actual_manifest_file = self.wait()
        actual_manifest_body = actual_manifest_file.read()
        self.assertEqual(actual_manifest_body, expected_manifest_body)

        #cleanup
        SharingController.remove_sharing_record_by_secret(sharing_secret, callback =self.stop)
        self.wait()
        StorageServer.remove_collection(self.__account_id, collection_name,
            callback=self.stop)
        for subscriber_id in subscribers_collections:
            subscriber_collection = subscribers_collections[subscriber_id]
            StorageServer.remove_collection(subscriber_id, subscriber_collection,
                callback=self.stop)
            self.wait()
Ejemplo n.º 12
0
    def test_add_subscriber(self):

        # create collection
        first_collection_name = "shareable_collection"
        file = open("../test_resources/XooML.xml")
        StorageServer.add_collection(
            user_id=self.__account_id, collection_name=first_collection_name, callback=self.stop, file=file
        )
        response = self.wait()
        self.assertEqual(StorageResponse.OK, response)

        # create sharing record
        SharingController.create_sharing_record(self.__account_id, first_collection_name, callback=self.stop)
        sharing_secret = self.wait(timeout=10000)
        self.assertTrue(sharing_secret is not None)

        # subscribe
        SharingController.subscribe_to_sharing_space(self.__subscriber_id, sharing_secret, callback=self.stop)
        subscribers_collection_name = self.wait()
        self.assertTrue(subscribers_collection_name is not None)

        # verify
        SharingController.get_sharing_record_by_secret(sharing_secret, callback=self.stop)
        sharing_record = self.wait()
        subscribers_list = sharing_record.get_subscribers()
        self.assertTrue([self.__subscriber_id, subscribers_collection_name] in subscribers_list)
        # verify subscriber collection
        SharingController.get_sharing_secret_from_subscriber_info(
            self.__subscriber_id, subscribers_collection_name, callback=self.stop
        )
        actual_sharing_secret = self.wait()
        self.assertEqual(sharing_secret, actual_sharing_secret)
        # cleanup
        SharingController.remove_sharing_record_by_secret(sharing_secret, callback=self.stop)
        self.wait()
        StorageServer.remove_collection(self.__account_id, first_collection_name, callback=self.stop)
        self.wait()
        StorageServer.remove_collection(self.__subscriber_id, subscribers_collection_name, callback=self.stop)
        self.wait()
Ejemplo n.º 13
0
    def test_invalid_user_unsubscribing(self):

        # create collection
        first_collection_name = "shareable_collection"
        file = open("../test_resources/XooML.xml")
        StorageServer.add_collection(
            user_id=self.__account_id, collection_name=first_collection_name, callback=self.stop, file=file
        )
        response = self.wait()
        self.assertEqual(StorageResponse.OK, response)

        # create sharing record
        SharingController.create_sharing_record(self.__account_id, first_collection_name, callback=self.stop)
        sharing_secret = self.wait()
        self.assertTrue(sharing_secret is not None)

        # subscribe
        SharingController.subscribe_to_sharing_space(self.__subscriber_id, sharing_secret, callback=self.stop)
        subscribers_collection_name = self.wait()
        self.assertTrue(subscribers_collection_name is not None)

        # invalid unsubscribe
        SharingController.unsubscribe_from_sharing_space("dummy", first_collection_name, callback=self.stop)
        response = self.wait()
        self.assertEqual(StorageResponse.NOT_FOUND, response)

        # verify unsubscribe
        SharingController.get_sharing_record_from_subscriber_info(
            "dummy", subscribers_collection_name, callback=self.stop
        )
        sharing_record = self.wait()
        self.assertTrue(sharing_record is None)

        # cleanup
        SharingController.remove_sharing_record_by_secret(sharing_secret, callback=self.stop)
        self.wait()
        StorageServer.remove_collection(self.__account_id, first_collection_name, callback=self.stop)
        self.wait()
        StorageServer.remove_collection(self.__subscriber_id, subscribers_collection_name, callback=self.stop)
Ejemplo n.º 14
0
    def test_update_thumbnail(self):

        collection_name = str(uuid.uuid4())
        subscriber_list = [self.__subscriber_id]
        sharing_secret, subscribers_collections =\
        self.__create_sharing_record(subscriber_list, collection_name)


        joker = JokerHelper.get_instance()
        joker.get_sharing_space_server(sharing_secret, callback=self.stop)
        server_adrs = self.wait(timeout=10000)
        self.assertIn(server_adrs, Properties.sharing_space_servers)

        thumbnail_file = open('../test_resources/note_img.jpg')
        joker.update_thumbnail(server_adrs, sharing_secret, self.__account_id,
            collection_name, thumbnail_file, callback=self.stop)
        response = self.wait()
        self.assertEqual(StorageResponse.OK, response)

        #wait for a while
        self.__wait(10)

        #try to retreive the thumbnail
        StorageServer.get_thumbnail(self.__account_id, collection_name,
            callback=self.stop)
        response = self.wait()
        self.assertTrue(response is not None)

        #cleanup
        SharingController.remove_sharing_record_by_secret(sharing_secret, callback =self.stop)
        self.wait()
        StorageServer.remove_collection(self.__account_id, collection_name,
            callback=self.stop)
        for subscriber_id in subscribers_collections:
            subscriber_collection = subscribers_collections[subscriber_id]
            StorageServer.remove_collection(subscriber_id, subscriber_collection,
                callback=self.stop)
            self.wait()
Ejemplo n.º 15
0
 def test_remove_sharing_record_by_owner_info(self):
     collection_name = "test_collection_name"
     SharingController.create_sharing_record(self.__account_id, collection_name, callback=self.stop)
     sharing_secret = self.wait()
     self.assertTrue(sharing_secret is not None)
     SharingController.remove_sharing_record_by_owner_info(self.__account_id, collection_name, callback=self.stop)
     self.wait(timeout=10)
     # verify
     SharingController.get_sharing_record_by_secret(sharing_secret, callback=self.stop)
     sharing_record = self.wait()
     self.assertTrue(sharing_record is None)
     # verify subscriber collection
     SharingController.get_sharing_secret_from_subscriber_info(
         self.__account_id, collection_name, callback=self.stop
     )
     actual_sharing_secret = self.wait()
     self.assertTrue(actual_sharing_secret is None)
Ejemplo n.º 16
0
 def test_get_sharing_record_by_sharing_secret(self):
     SharingController.create_sharing_record(self.__account_id, "test_collection", callback=self.stop)
     sharing_secret = self.wait()
     self.assertTrue(sharing_secret is not None)
     SharingController.get_sharing_record_by_secret(sharing_secret, callback=self.stop)
     sharing_record = self.wait()
     actual_sharing_secret = sharing_record.toDictionary()[SharingRecord.SECRET_KEY]
     self.assertEqual(sharing_secret, actual_sharing_secret)
     # cleanup
     SharingController.remove_sharing_record_by_secret(sharing_secret, callback=self.stop)
     self.wait()
Ejemplo n.º 17
0
    def test_get_sharing_record_from_subscriber_info_non_existing_subscriber(self):
        collection_name = "col_name"
        SharingController.create_sharing_record(self.__account_id, collection_name, callback=self.stop)
        sharing_secret = self.wait()
        self.assertTrue(sharing_secret is not None)

        SharingController.get_sharing_record_from_subscriber_info("dummy_account", collection_name, callback=self.stop)
        sharing_record = self.wait()
        self.assertTrue(sharing_record is None)

        # cleanup
        SharingController.remove_sharing_record_by_secret(sharing_secret, callback=self.stop)
        self.wait()
Ejemplo n.º 18
0
    def test_get_sharing_record_by_owner_info(self):
        collection_name = "col_name"
        SharingController.create_sharing_record(self.__account_id, collection_name, callback=self.stop)
        sharing_secret = self.wait()
        self.assertTrue(sharing_secret is not None)

        SharingController.get_sharing_record_by_owner_info(self.__account_id, collection_name, callback=self.stop)
        sharing_record = self.wait()
        actual_sharing_secret = sharing_record.get_sharing_secret()
        self.assertEqual(sharing_secret, actual_sharing_secret)
        # cleanup
        SharingController.remove_sharing_record_by_secret(sharing_secret, callback=self.stop)
        self.wait()
Ejemplo n.º 19
0
    def test_remove_subscriber_from_subscriber_collection(self):

        collection_name = "dummy_collection"
        sharing_secret = "secret"
        SharingController.add_subscriber(self.__account_id, collection_name, sharing_secret, callback=self.stop)
        self.wait()

        SharingController.get_sharing_secret_from_subscriber_info(
            self.__account_id, collection_name, callback=self.stop
        )
        actual_sharing_secret = self.wait()
        self.assertEqual(sharing_secret, actual_sharing_secret)

        SharingController.remove_subscriber(self.__account_id, collection_name, callback=self.stop)
        self.wait()

        SharingController.get_sharing_secret_from_subscriber_info(
            self.__account_id, collection_name, callback=self.stop
        )
        actual_sharing_secret = self.wait()
        self.assertTrue(actual_sharing_secret is None)
Ejemplo n.º 20
0
    def test_save_sharing_record(self):
        collection_name = "test_collection"
        SharingController.create_sharing_record(self.__account_id, collection_name, callback=self.stop)
        sharing_secret = self.wait()
        self.assertTrue(sharing_secret is not None)

        # verify subscriber collection
        SharingController.get_sharing_secret_from_subscriber_info(
            self.__account_id, collection_name, callback=self.stop
        )
        actual_sharing_secret = self.wait()
        self.assertEqual(sharing_secret, actual_sharing_secret)

        # cleanup
        SharingController.remove_sharing_record_by_secret(sharing_secret, callback=self.stop)
        self.wait()
Ejemplo n.º 21
0
    def test_rename_shared_collection_subscriber(self):

        # create collection
        first_collection_name = "shareable_collection" + str(random.randint)
        file = open("../test_resources/XooML.xml")
        StorageServer.add_collection(
            user_id=self.__account_id, collection_name=first_collection_name, callback=self.stop, file=file
        )
        response = self.wait()
        self.assertEqual(StorageResponse.OK, response)

        # create sharing record
        SharingController.create_sharing_record(self.__account_id, first_collection_name, callback=self.stop)
        sharing_secret = self.wait()
        self.assertTrue(sharing_secret is not None)

        # subscribe
        SharingController.subscribe_to_sharing_space(self.__subscriber_id, sharing_secret, callback=self.stop)
        subscribers_collection_name = self.wait()
        self.assertTrue(subscribers_collection_name is not None)

        # rename
        new_collection_name = "new_name" + str(random.randint)
        SharingController.rename_shared_collection(
            self.__subscriber_id, subscribers_collection_name, new_collection_name, callback=self.stop
        )
        response_code = self.wait()
        self.assertTrue(StorageResponse.OK, response_code)

        # verify
        SharingController.get_sharing_record_by_secret(sharing_secret, callback=self.stop)
        sharing_record = self.wait()
        renamed_collection_name = sharing_record.get_collection_name_for_subscriber(self.__subscriber_id)
        self.assertEqual(new_collection_name, renamed_collection_name)
        owner_collection_name = sharing_record.get_owner_collection_name()
        self.assertEqual(first_collection_name, owner_collection_name)

        # verify subscriber collection
        SharingController.get_sharing_secret_from_subscriber_info(
            self.__subscriber_id, new_collection_name, callback=self.stop
        )
        renamed_sharing_secret = self.wait()
        self.assertEqual(sharing_secret, renamed_sharing_secret)

        # cleanup
        SharingController.remove_sharing_record_by_secret(sharing_secret, callback=self.stop)
        self.wait()
        StorageServer.remove_collection(self.__account_id, first_collection_name, callback=self.stop)
        self.wait()
        StorageServer.remove_collection(self.__subscriber_id, subscribers_collection_name, callback=self.stop)
        self.wait()
Ejemplo n.º 22
0
    def test_load_balancing_increasing_decreasing_load(self):

        servers = ['a', 'b', 'c']
        Properties.sharing_space_servers = servers
        collection_name1 = str(uuid.uuid4())
        subscriber_list1 = [self.__subscriber_id, self.__second_subscriber_id]
        sharing_secret1, subscribers_collections1 =\
        self.__create_sharing_record(subscriber_list1, collection_name1)
        load_balancer = SharingLoadBalancer()
        load_balancer.get_sharing_space_info(sharing_secret1, callback=self.stop)
        server_info1 = self.wait()
        server_adrs1 = server_info1['server']
        print server_adrs1
        self.assertTrue(server_adrs1 in servers)

        collection_name2 = str(uuid.uuid4())
        subscriber_list2 = [self.__subscriber_id]
        sharing_secret2, subscribers_collections2 =\
        self.__create_sharing_record(subscriber_list2, collection_name2)
        load_balancer.get_sharing_space_info(sharing_secret2, callback=self.stop)
        server_info2 = self.wait()
        server_adrs2 = server_info2['server']
        print server_adrs2
        self.assertTrue(server_adrs2 in servers)
        self.assertNotEqual(server_adrs2, server_adrs1)


        collection_name3 = str(uuid.uuid4())
        subscriber_list3 = [self.__subscriber_id, self.__second_subscriber_id]
        sharing_secret3, subscribers_collections3 =\
        self.__create_sharing_record(subscriber_list3, collection_name3)
        load_balancer.get_sharing_space_info(sharing_secret3, callback=self.stop)
        server_info3 = self.wait()
        server_adrs3 = server_info3['server']
        print server_adrs3
        self.assertTrue(server_adrs3 in servers)
        self.assertNotEqual(server_adrs3, server_adrs1)
        self.assertNotEqual(server_adrs3, server_adrs2)


        load_balancer.remove_sharing_space_info(sharing_secret1, callback=self.stop)
        self.wait()

        collection_name4 = str(uuid.uuid4())
        subscriber_list4 = [self.__subscriber_id, self.__second_subscriber_id]
        sharing_secret4, subscribers_collections4 =\
        self.__create_sharing_record(subscriber_list4, collection_name4)
        load_balancer.get_sharing_space_info(sharing_secret4, callback=self.stop)
        server_info4 = self.wait()
        server_adrs4 = server_info4['server']
        print server_adrs4
        self.assertTrue(server_adrs4 in servers)
        self.assertEqual(server_adrs4, server_adrs1)


        #cleanup
        SharingController.remove_sharing_record_by_secret(sharing_secret1, callback =self.stop)
        self.wait()
        StorageServer.remove_collection(self.__account_id, collection_name1,
            callback=self.stop)
        for subscriber_id in subscribers_collections1:
            subscriber_collection = subscribers_collections1[subscriber_id]
            StorageServer.remove_collection(subscriber_id, subscriber_collection,
                callback=self.stop)
            self.wait()

        SharingController.remove_sharing_record_by_secret(sharing_secret2, callback =self.stop)
        self.wait()
        StorageServer.remove_collection(self.__account_id, collection_name2,
            callback=self.stop)
        for subscriber_id in subscribers_collections2:
            subscriber_collection = subscribers_collections2[subscriber_id]
            StorageServer.remove_collection(subscriber_id, subscriber_collection,
                callback=self.stop)
            self.wait()

        SharingController.remove_sharing_record_by_secret(sharing_secret3, callback =self.stop)
        self.wait()
        StorageServer.remove_collection(self.__account_id, collection_name3,
            callback=self.stop)
        for subscriber_id in subscribers_collections3:
            subscriber_collection = subscribers_collections3[subscriber_id]
            StorageServer.remove_collection(subscriber_id, subscriber_collection,
                callback=self.stop)
            self.wait()

        SharingController.remove_sharing_record_by_secret(sharing_secret4, callback =self.stop)
        self.wait()
        StorageServer.remove_collection(self.__account_id, collection_name4,
            callback=self.stop)
        for subscriber_id in subscribers_collections4:
            subscriber_collection = subscribers_collections4[subscriber_id]
            StorageServer.remove_collection(subscriber_id, subscriber_collection,
                callback=self.stop)
            self.wait()
Ejemplo n.º 23
0
 def test_get_invalid_sharing_record_by_owner_info(self):
     SharingController.get_sharing_record_by_owner_info(self.__account_id, "dummy", callback=self.stop)
     sharing_record = self.wait()
     self.assertTrue(sharing_record is None)
Ejemplo n.º 24
0
 def test_get_non_existing_sharing_record(self):
     SharingController.get_sharing_record_by_secret("invalidsecret", callback=self.stop)
     sharing_record = self.wait()
     self.assertTrue(sharing_record is None)
Ejemplo n.º 25
0
    def test_remove_all_subscribers_detailed(self):

        # create collection
        first_collection_name = "shareable_collection"
        file = open("../test_resources/XooML.xml")
        StorageServer.add_collection(
            user_id=self.__account_id, collection_name=first_collection_name, callback=self.stop, file=file
        )
        response = self.wait()
        self.assertEqual(StorageResponse.OK, response)

        # create sharing record
        SharingController.create_sharing_record(self.__account_id, first_collection_name, callback=self.stop)
        sharing_secret = self.wait()
        self.assertTrue(sharing_secret is not None)

        # subscribe
        SharingController.subscribe_to_sharing_space(self.__subscriber_id, sharing_secret, callback=self.stop)
        subscribers_collection_name = self.wait()
        self.assertTrue(subscribers_collection_name is not None)

        # remove all subscribers
        SharingController.remove_all_subscribers(sharing_secret, callback=self.stop)
        self.wait()

        # verify removed subscribers from subscriber table
        SharingController.get_sharing_record_from_subscriber_info(
            self.__subscriber_id, subscribers_collection_name, callback=self.stop
        )
        sharing_record = self.wait()
        self.assertTrue(sharing_record is None)
        SharingController.get_sharing_record_from_subscriber_info(
            self.__account_id, first_collection_name, callback=self.stop
        )
        sharing_record = self.wait()
        self.assertTrue(sharing_record is None)

        # cleanup
        SharingController.remove_sharing_record_by_secret(sharing_secret, callback=self.stop)
        self.wait()
        StorageServer.remove_collection(self.__account_id, first_collection_name, callback=self.stop)
        self.wait()
        StorageServer.remove_collection(self.__subscriber_id, subscribers_collection_name, callback=self.stop)
        self.wait()
Ejemplo n.º 26
0
    def test_rename_invalid_shared_collection(self):

        new_collection_name = "new_name" + str(random.randint)
        SharingController.rename_shared_collection(self.__account_id, "looloo", new_collection_name, callback=self.stop)
        response_code = self.wait()
        self.assertTrue(StorageResponse.NOT_FOUND, response_code)
Ejemplo n.º 27
0
    def test_get_sharing_record_from_subscriber_info_non_existing_shared_space(self):

        SharingController.get_sharing_record_from_subscriber_info(self.__account_id, "dummy", callback=self.stop)
        sharing_record = self.wait()
        self.assertTrue(sharing_record is None)