~rlane/nova/lp773690

« back to all changes in this revision

Viewing changes to nova/tests/api/openstack/test_servers.py

  • Committer: rlane at wikimedia
  • Date: 2011-04-29 22:30:40 UTC
  • mfrom: (382.1.655 nova)
  • Revision ID: rlane@wikimedia.org-20110429223040-i0x3ds9eqwrabyru
MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
 
80
80
    inst_type = instance_types.get_instance_type_by_flavor_id(1)
81
81
 
82
 
    if public_addresses == None:
 
82
    if public_addresses is None:
83
83
        public_addresses = list()
84
84
 
85
 
    if host != None:
 
85
    if host is not None:
86
86
        host = str(host)
87
87
 
88
88
    instance = {
613
613
        res = req.get_response(fakes.wsgi_app())
614
614
        self.assertEqual(res.status_int, 400)
615
615
 
 
616
    def test_create_instance_with_admin_pass_v10(self):
 
617
        self._setup_for_create_instance()
 
618
 
 
619
        body = {
 
620
            'server': {
 
621
                'name': 'test-server-create',
 
622
                'imageId': 3,
 
623
                'flavorId': 1,
 
624
                'adminPass': 'testpass',
 
625
            },
 
626
        }
 
627
 
 
628
        req = webob.Request.blank('/v1.0/servers')
 
629
        req.method = 'POST'
 
630
        req.body = json.dumps(body)
 
631
        req.headers['content-type'] = "application/json"
 
632
        res = req.get_response(fakes.wsgi_app())
 
633
        res = json.loads(res.body)
 
634
        self.assertNotEqual(res['server']['adminPass'],
 
635
                            body['server']['adminPass'])
 
636
 
 
637
    def test_create_instance_with_admin_pass_v11(self):
 
638
        self._setup_for_create_instance()
 
639
 
 
640
        imageRef = 'http://localhost/v1.1/images/2'
 
641
        flavorRef = 'http://localhost/v1.1/flavors/3'
 
642
        body = {
 
643
            'server': {
 
644
                'name': 'server_test',
 
645
                'imageRef': imageRef,
 
646
                'flavorRef': flavorRef,
 
647
                'adminPass': 'testpass',
 
648
            },
 
649
        }
 
650
 
 
651
        req = webob.Request.blank('/v1.1/servers')
 
652
        req.method = 'POST'
 
653
        req.body = json.dumps(body)
 
654
        req.headers['content-type'] = "application/json"
 
655
        res = req.get_response(fakes.wsgi_app())
 
656
        server = json.loads(res.body)['server']
 
657
        self.assertEqual(server['adminPass'], body['server']['adminPass'])
 
658
 
 
659
    def test_create_instance_with_empty_admin_pass_v11(self):
 
660
        self._setup_for_create_instance()
 
661
 
 
662
        imageRef = 'http://localhost/v1.1/images/2'
 
663
        flavorRef = 'http://localhost/v1.1/flavors/3'
 
664
        body = {
 
665
            'server': {
 
666
                'name': 'server_test',
 
667
                'imageRef': imageRef,
 
668
                'flavorRef': flavorRef,
 
669
                'adminPass': '',
 
670
            },
 
671
        }
 
672
 
 
673
        req = webob.Request.blank('/v1.1/servers')
 
674
        req.method = 'POST'
 
675
        req.body = json.dumps(body)
 
676
        req.headers['content-type'] = "application/json"
 
677
        res = req.get_response(fakes.wsgi_app())
 
678
        self.assertEqual(res.status_int, 400)
 
679
 
616
680
    def test_update_no_body(self):
617
681
        req = webob.Request.blank('/v1.0/servers/1')
618
682
        req.method = 'PUT'