def test_find_airport_password(self): system_keychain = Keychain("/Library/Keychains/System.keychain") try: system_keychain.find_generic_password(account_name="linksys") except KeyError: print >> sys.stderr, "test_find_airport_password: assuming the non-existence of linksys SSID is correct" pass
def test_find_airport_password(self): system_keychain = Keychain("/Library/Keychains/System.keychain") try: system_keychain.find_generic_password(account_name="linksys") except KeyError: print >> sys.stderr, "test_find_airport_password: assuming the non-existence of linksys SSID is correct" pass
def main(): parser = OptionParser(__doc__.strip()) parser.add_option('-a', '--account', '--account-name', help="Set the account name" ) parser.add_option('-s', '--service', '--service-name', help="Set the service name" ) parser.add_option('-k', '--keychain', help="Path to the keychain file" ) (options, args) = parser.parse_args() if not options.keychain and os.getuid() == 0: options.keychain = "/Library/Keychains/System.keychain" if not (options.account or options.service): parser.error("You must specify either an account or service name") try: keychain = Keychain(options.keychain) item = keychain.find_generic_password( service_name=options.service, account_name=options.account ) print "Removing %s" % item keychain.remove(item) except KeyError, exc: print >>sys.stderr, exc.message sys.exit(0)
def test_add_and_remove_generic_password(self): import uuid k = Keychain() service_name = "PyMacAdmin Keychain Unit Test" account_name = str(uuid.uuid4()) password = str(uuid.uuid4()) i = GenericPassword(service_name=service_name, account_name=account_name, password=password) k.add(i) self.assertEquals(i.password, k.find_generic_password(service_name, account_name).password) k.remove(i) self.assertRaises(KeyError, k.find_generic_password, **{"service_name": service_name, "account_name": account_name})
def main(): if len(sys.argv) < 3: print >> sys.stderr, __doc__.strip() sys.exit(1) ssid, new_password = sys.argv[1:3] if os.getuid() == 0: keychain = Keychain("/Library/Keychains/System.keychain") else: keychain = Keychain() try: item = keychain.find_generic_password(account_name=ssid) if item.password != new_password: item.update_password(new_password) except RuntimeError, exc: print >> sys.stderr, "Unable to change password for Airport network %s: %s" % (ssid, exc) sys.exit(1)
def main(): if len(sys.argv) < 3: print >> sys.stderr, __doc__.strip() sys.exit(1) ssid, new_password = sys.argv[1:3] if os.getuid() == 0: keychain = Keychain("/Library/Keychains/System.keychain") else: keychain = Keychain() try: item = keychain.find_generic_password(account_name=ssid) if item.password != new_password: item.update_password(new_password) except RuntimeError, exc: print >> sys.stderr, "Unable to change password for Airport network %s: %s" % ( ssid, exc) sys.exit(1)
def test_add_and_remove_generic_password(self): import uuid k = Keychain() service_name = "PyMacAdmin Keychain Unit Test" account_name = str(uuid.uuid4()) password = str(uuid.uuid4()) i = GenericPassword(service_name=service_name, account_name=account_name, password=password) k.add(i) self.assertEquals( i.password, k.find_generic_password(service_name, account_name).password) k.remove(i) self.assertRaises( KeyError, k.find_generic_password, **{ "service_name": service_name, "account_name": account_name })
def test_find_airport_password(self): system_keychain = Keychain("/Library/Keychains/System.keychain") system_keychain.find_generic_password(account_name="linksys") # BUG: Most people probably have this - but not everyone?