Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
sudo: false
language: python
python:
- "2.7"
- "3.5"
- "3.6"
install:
- pip install -r requirements.txt
script:
- python -m unittest discover -s tests
13 changes: 10 additions & 3 deletions tests/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,28 @@
from tests import unittest


THIS_FOLDER = os.path.dirname(__file__)
CONFIG_FILE = os.path.join(THIS_FOLDER, 'config.json')


@unittest.skipUnless(os.path.exists(CONFIG_FILE), "%s missing" % CONFIG_FILE)
class TestConfidentialClientApplication(unittest.TestCase):
same_folder = os.path.dirname(__file__)
config = json.load(open(os.path.join(same_folder, 'config.json')))
scope = ["https://graph.microsoft.com/.default"]
scope2 = ["User.Read"]
scope_rt = ["offline_access"]

@classmethod
def setUpClass(cls):
cls.config = json.load(open(CONFIG_FILE))

def test_confidential_client_using_secret(self):
app = ConfidentialClientApplication(
self.config['CLIENT_ID'], self.config['CLIENT_SECRET'])
result = app.acquire_token_for_client(self.scope)
self.assertIn('access_token', result)

def test_confidential_client_using_certificate(self):
private_key = os.path.join(self.same_folder, self.config['PRIVATE_KEY'])
private_key = os.path.join(THIS_FOLDER, self.config['PRIVATE_KEY'])
with open(private_key) as f: pem = f.read()
certificate = {
'certificate': pem,
Expand Down