Esempio n. 1
0
    def test_token_credential(self):
        token_credential = TokenCredential(self.generate_oauth_token())

        # Action 1: make sure token works
        service = QueueService(self.settings.STORAGE_ACCOUNT_NAME, token_credential=token_credential)
        queues = list(service.list_queues())
        self.assertIsNotNone(queues)

        # Action 2: change token value to make request fail
        token_credential.token = "YOU SHALL NOT PASS"
        with self.assertRaises(AzureException):
            queues = list(service.list_queues())
            self.assertIsNone(queues)

        # Action 3: update token to make it working again
        token_credential.token = self.generate_oauth_token()
        queues = list(service.list_queues())
        self.assertIsNotNone(queues)
    def test_token_credential(self):
        token_credential = TokenCredential(self.generate_oauth_token())

        # Action 1: make sure token works
        service = BlockBlobService(self.settings.OAUTH_STORAGE_ACCOUNT_NAME,
                                   token_credential=token_credential)
        result = service.exists("test")
        self.assertIsNotNone(result)

        # Action 2: change token value to make request fail
        token_credential.token = "YOU SHALL NOT PASS"
        with self.assertRaises(AzureException):
            result = service.exists("test")
            self.assertIsNone(result)

        # Action 3: update token to make it working again
        token_credential.token = self.generate_oauth_token()
        result = service.exists("test")
        self.assertIsNotNone(result)