Skip to content
Open
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
8 changes: 7 additions & 1 deletion pyexchange/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""
import requests
from requests_ntlm import HttpNtlmAuth
from requests.auth import HTTPBasicAuth

import logging

Expand Down Expand Up @@ -39,7 +40,8 @@ def build_password_manager(self):

log.debug(u'Constructing password manager')

self.password_manager = HttpNtlmAuth(self.username, self.password)
# self.password_manager = HttpNtlmAuth(self.username, self.password)
self.password_manager = HTTPBasicAuth(self.username, self.password)

return self.password_manager

Expand All @@ -62,6 +64,10 @@ def send(self, body, headers=None, retries=2, timeout=30, encoding=u"utf-8"):

try:
response = self.session.post(self.url, data=body, headers=headers, verify = self.verify_certificate)
if response.status_code == 401:
self.password_manager = HttpNtlmAuth(self.username, self.password)
self.session.auth = self.password_manager
response = self.session.post(self.url, data=body, headers=headers, verify = self.verify_certificate)
response.raise_for_status()
except requests.exceptions.RequestException as err:
log.debug(err.response.content)
Expand Down
6 changes: 6 additions & 0 deletions pyexchange/exchange2010/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,8 @@ def _parse_response_for_get_event(self, response):

result['_conflicting_event_ids'] = self._parse_event_conflicts(response)

result[u'categories'] = self._parse_event_categories(response)

return result

def _parse_event_properties(self, response):
Expand Down Expand Up @@ -707,6 +709,10 @@ def _parse_event_conflicts(self, response):
conflicting_ids = response.xpath(u'//m:Items/t:CalendarItem/t:ConflictingMeetings/t:CalendarItem/t:ItemId', namespaces=soap_request.NAMESPACES)
return [id_element.get(u"Id") for id_element in conflicting_ids]

def _parse_event_categories(self, response):
categories = response.xpath(u'//m:Items/t:CalendarItem/t:Categories/t:String', namespaces=soap_request.NAMESPACES)
return [category.text for category in categories]


class Exchange2010FolderService(BaseExchangeFolderService):

Expand Down
4 changes: 4 additions & 0 deletions tests/exchange2010/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@
<t:LastResponseTime>{resource.last_response:%Y-%m-%dT%H:%M:%SZ}</t:LastResponseTime>
</t:Attendee>
</t:Resources>
<t:Categories>
<t:String>dino</t:String>
<t:String>saur</t:String>
</t:Categories>

<t:ConflictingMeetingCount>1</t:ConflictingMeetingCount>
<t:AdjacentMeetingCount>1</t:AdjacentMeetingCount>
Expand Down
3 changes: 3 additions & 0 deletions tests/exchange2010/test_get_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ def test_required_attendees_are_required(self):
def test_optional_attendees_are_optional(self):
assert sorted(self.event.optional_attendees) == sorted(OPTIONAL_PEOPLE)

def test_categories_are_correct(self):
assert sorted(self.event.categories) == sorted(["dino", "saur"])

def test_conflicting_event_ids(self):
assert self.event.conflicting_event_ids[0] == TEST_CONFLICT_EVENT.id

Expand Down