Ejemplo n.º 1
0
 def add_service_public_key(self,
                            service_id,
                            public_key,
                            expires=None,
                            active=None):
     """
     Adds a public key to a Directory Service
     :param service_id: Unique Service ID
     :param public_key: String RSA public key
     :param expires: Optional datetime.datetime stating a time in which the key will no longer be valid
     :param active: Optional bool stating whether the key should be considered active and usable.
     :raise: launchkey.exceptions.InvalidParameters - Input parameters were not correct
     :raise: launchkey.exceptions.InvalidPublicKey - The public key you supplied is not valid.
     :raise: launchkey.exceptions.PublicKeyAlreadyInUse - The public key you supplied already exists for the
                                                             requested entity. It cannot be added again.
     :raise: launchkey.exceptions.Forbidden - The Service you requested either does not exist or you do not have
                                              sufficient permissions.
     :return: MD5 fingerprint (key_id) of the public key, IE: e0:2f:a9:5a:76:92:6b:b5:4d:24:67:19:d1:8a:0a:75
     """
     kwargs = {"service_id": str(service_id), "public_key": public_key}
     if expires is not None:
         kwargs['date_expires'] = iso_format(expires)
     if active is not None:
         kwargs['active'] = active
     return self._transport.post("/organization/v3/service/keys",
                                 self._subject, **kwargs).data['key_id']
Ejemplo n.º 2
0
 def test_iso_format_success(self):
     self.assertEqual(
         "2017-10-03T22:50:15Z",
         iso_format(
             datetime(year=2017,
                      month=10,
                      day=3,
                      hour=22,
                      minute=50,
                      second=15,
                      tzinfo=pytz.timezone("UTC"))))
Ejemplo n.º 3
0
 def update_service_public_key(self, service_id, key_id, expires=False, active=None):
     """
     Removes a public key from an Organization Service
     :param service_id: Unique Service ID
     :param key_id: MD5 fingerprint of the public key, IE: e0:2f:a9:5a:76:92:6b:b5:4d:24:67:19:d1:8a:0a:75
     :param expires: datetime.datetime stating a time in which the key will no longer be valid
     :param active: Bool stating whether the key should be considered active and usable
     :raise: launchkey.exceptions.PublicKeyDoesNotExist - The key_id you supplied could not be found
     :raise: launchkey.exceptions.Forbidden - The Service you requested either does not exist or you do not have
                                              sufficient permissions.
     :return:
     """
     kwargs = {"service_id": str(service_id), "key_id": key_id}
     if active is not None:
         kwargs['active'] = active
     if expires is not False:
         kwargs['date_expires'] = iso_format(expires)
     self._transport.patch("/organization/v3/service/keys", self._subject, **kwargs)
Ejemplo n.º 4
0
 def test_iso_format_none(self):
     self.assertIsNone(iso_format(None))