Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Promotion extra now fixes DSN to use server-specific postgres

  • Loading branch information
m0rgen committed Oct 19, 2012
2 parents dc7dff5 + 991ec9e commit ebaf31727b0898c578f1726efd35578fd1a79bf5
Showing with 80 additions and 9 deletions.
  1. +20 −9 contrib/migration/calendarpromotion.py
  2. +60 −0 contrib/migration/test/test_promotion.py
@@ -24,6 +24,23 @@
GROUP_NAME = "calendar"
LOG_DIR = "/var/log/caldavd"


def updatePlist(plistData):
"""
Update the passed-in plist data with new values for disabling the XMPPNotifier, and
to set the DSN to use the server-specific Postgres.
@param plistData: the plist data to update in place
@type plistData: C{dict}
"""
try:
if plistData["Notifications"]["Services"]["XMPPNotifier"]["Enabled"]:
plistData["Notifications"]["Services"]["XMPPNotifier"]["Enabled"] = False
except KeyError:
pass
plistData["DSN"] = "/Library/Server/PostgreSQL For Server Services/Socket:caldav:caldav:::"


def main():

try:
@@ -45,17 +62,11 @@ def main():
if os.path.exists(plistPath):
try:
plistData = readPlist(plistPath)

# Disable XMPPNotifier now that we're directly talking to APNS
try:
if plistData["Notifications"]["Services"]["XMPPNotifier"]["Enabled"]:
plistData["Notifications"]["Services"]["XMPPNotifier"]["Enabled"] = False
writePlist(plistData, plistPath)
except KeyError:
pass
updatePlist(plistData)
writePlist(plistData, plistPath)

except Exception, e:
print "Unable to disable XMPP in %s: %s" % (plistPath, e)
print "Unable to disable update values in %s: %s" % (plistPath, e)

else:
# Copy configuration
@@ -0,0 +1,60 @@
##
# Copyright (c) 2012 Apple Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##

import twistedcaldav.test.util
from contrib.migration.calendarpromotion import updatePlist

class PromotionTests(twistedcaldav.test.util.TestCase):
"""
Calendar Server Promotion Tests
"""

def test_updatePlist(self):
"""
Verify XMPPNotifier is disabled and DSN is updated
"""

orig = {
"ignored" : "ignored",
}
expected = {
"ignored" : "ignored",
"DSN" : "/Library/Server/PostgreSQL For Server Services/Socket:caldav:caldav:::",
}
updatePlist(orig)
self.assertEquals(orig, expected)

orig = {
"Notifications" : {
"Services" : {
"XMPPNotifier" : {
"Enabled" : True
}
}
}
}
expected = {
"Notifications" : {
"Services" : {
"XMPPNotifier" : {
"Enabled" : False
}
}
},
"DSN" : "/Library/Server/PostgreSQL For Server Services/Socket:caldav:caldav:::",
}
updatePlist(orig)
self.assertEquals(orig, expected)

0 comments on commit ebaf317

Please sign in to comment.
You can’t perform that action at this time.