def test_with_password_success(self, mock):
     '''POST /host/allocate with success response (using password auth)'''
     mock.register_uri(
         'POST',
         '{0}/host/allocate'.format(self.endpoint),
         json={
             'id': self.opts.host_id,
             'os': 'linux',
             'endpoint': {
                 'ip': self.opts.host,
                 'port': self.opts.port,
                 'protocol': self.opts.protocol
             },
             'credentials': {
                 'username': self.opts.username,
                 'password': self.opts.password
             }
         },
         status_code=httplib.OK
     )
     tasks.acquire(self.endpoint, requested_os='linux', ctx=self.ctx)
     self.assertEqual(self.ctx.instance.runtime_properties['host_id'],
                      self.opts.host_id)
     self.assertEqual(self.ctx.instance.runtime_properties['user'],
                      self.opts.username)
     self.assertEqual(self.ctx.instance.runtime_properties['password'],
                      self.opts.password)
     self.assertEqual(self.ctx.instance.runtime_properties['ip'],
                      self.opts.host)
 def test_acquire_good_response(self):
     with requests_mock.mock() as m:
         m.post('{0}/hosts'.format(self.service_url),
                content=json.dumps(self.good_response_acquire_password),
                status_code=requests.codes.CREATED)
         tasks.acquire(self.service_url, ctx=self.ctx)
     self.assertEqual(self.ctx.instance.runtime_properties['user'],
                      self.username)
     self.assertEqual(self.ctx.instance.runtime_properties['password'],
                      self.password)
     self.assertEqual(self.ctx.instance.runtime_properties['ip'], self.host)
 def test_acquire_good_response(self):
     with requests_mock.mock() as m:
         m.post('{0}/hosts'.format(self.service_url),
                content=json.dumps(self.good_response_acquire_password),
                status_code=requests.codes.CREATED)
         tasks.acquire(self.service_url, ctx=self.ctx)
     self.assertEqual(self.ctx.instance.runtime_properties['user'],
                      self.username)
     self.assertEqual(self.ctx.instance.runtime_properties['password'],
                      self.password)
     self.assertEqual(self.ctx.instance.runtime_properties['ip'], self.host)