Ejemplo n.º 1
0
    def test_token_file_ignoring_comments(self):
        """
        Test a valid login using the password file lambda. The file itself will
        contain comments to be ignored. This test will require that the test be
        able to write to a temp directory
        """
        #setup
        token_file = "/tmp/__test_token_file__.txt"
        util.delete_file(token_file)
        expected_token = "file-token"
        token_file_content = "#ignore this line\n" + expected_token
        common.write_file(token_file, token_file_content)

        #tests
        actual_token = common.read_file(token_file)
        self.assertEqual(token_file_content, actual_token)

        options = {'cmr.token.file': token_file}
        self.assertEqual(expected_token, token.token_file(options))

        actual = str(token.token(token.token_file, options))
        self.assertEqual(expected_token, actual)

        #cleanup
        util.delete_file(token_file)
Ejemplo n.º 2
0
    def test_bearer(self):
        """Test a that a token can be returned as a Bearer token"""
        #setup
        token_file = "/tmp/__test_token_file__.txt"
        util.delete_file(token_file)
        expected_token = "file-token"
        expected_bearer = "Bearer " + expected_token
        common.write_file(token_file, expected_token)

        #tests
        options = {'cmr.token.file': token_file}
        actual = str(token.bearer(token.token_file, options))
        self.assertEqual(expected_bearer, actual, "Token formated as Bearer")

        #cleanup
        util.delete_file(token_file)
Ejemplo n.º 3
0
    def test_token_file(self):
        """
        Test a valid login using the password file lambda with caching on. This
        will require that the test be able to write to a temp directory
        """
        #setup
        token_file = "/tmp/__test_token_file__.txt"
        util.delete_file(token_file)
        expected_token = "file-token"
        common.write_file(token_file, expected_token)

        #tests
        options = {'cmr.token.file': token_file}
        self.assertEqual(expected_token, token.token_file(options))

        actual = str(token.token(token.token_file, options))
        self.assertEqual(expected_token, actual)

        actual_token = common.read_file(token_file)
        self.assertEqual(expected_token, actual_token)

        #cleanup
        util.delete_file(token_file)