Пример #1
0
 async def test_get_share_details(self):
     """Test get_share_details API binding."""
     with self.patch_signature, self.session_open_patch:
         async with SwiftXAccountSharing("http://example") as client:
             await client.get_share_details(
                 "test-user",
                 "test-container"
             )
Пример #2
0
 async def test_share_delete_access(self):
     """Test share_delete_access API binding."""
     with self.patch_signature, self.session_open_patch:
         async with SwiftXAccountSharing("http://example") as client:
             await client.share_delete_access(
                 "test-user",
                 "test-container",
                 ["test-user1", "test-user2", "test-user3"],
             )
Пример #3
0
    async def _push_share(self, container, recipient, rights):
        """Wrap the async share_new_access function."""
        sharing_client_url = os.environ.get("SWIFT_SHARING_URL", None)

        if not sharing_client_url:
            logging.log(
                logging.ERROR, "Swift Sharing APIs environment variables "
                "haven't been sourced. Please source the file if it is "
                "available, or download a new one from the storage UI.")

        sharing_client = SwiftXAccountSharing(sharing_client_url)

        async with sharing_client:
            await sharing_client.share_new_access(
                os.environ.get("OS_PROJECT_ID", None), container, recipient,
                rights, self._get_address())
Пример #4
0
    async def _push_share(
            self,
            container: str,
            recipient: typing.List[str],
            rights: typing.List[str]
    ) -> None:
        """Wrap the async share_new_access function."""
        sharing_client_url = os.environ.get("SWIFT_SHARING_URL", None)

        if not sharing_client_url:
            logging.log(
                logging.ERROR,
                "Swift Sharing APIs environment variables "
                "haven't been sourced. Please source the file if it is "
                "available, or download a new one from the storage UI."
            )
            sys.exit(-1)

        sharing_client = SwiftXAccountSharing(sharing_client_url)

        async with sharing_client:
            try:
                logging.log(logging.INFO, f"Sharing container: "
                            f"{container} for recipient {recipient}")
                await sharing_client.share_new_access(
                    os.environ.get("OS_PROJECT_ID", None),
                    container,
                    recipient,
                    rights,
                    self._get_address()
                )
            except AttributeError:
                logging.log(
                    logging.ERROR,
                    "Swift SharingAPIs environment variables "
                    "haven't been sourced. Please source the file if it is "
                    "available, or download a new one from the storage UI."
                )
                sys.exit(-1)
Пример #5
0
 async def test_parse_list_to_string(self):
     """Test parsing lists to string as a comma separated values."""
     to_parse = ["a", "b", "c", "d"]
     ret = SwiftXAccountSharing.parse_list_to_string(to_parse)
     self.assertEqual(ret, "a,b,c,d")