~ubuntu-branches/ubuntu/trusty/heat/trusty-security

« back to all changes in this revision

Viewing changes to heat/tests/test_api_cfn_v1.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Yolanda Robla, Chuck Short
  • Date: 2013-07-22 16:22:29 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20130722162229-zzvfu40id94ii0hc
Tags: 2013.2~b2-0ubuntu1
[ Yolanda Robla ]
* debian/tests: added autopkg tests

[ Chuck Short ]
* New upstream release
* debian/control:
  - Add python-pbr to build-depends.
  - Add python-d2to to build-depends.
  - Dropped python-argparse.
  - Add python-six to build-depends.
  - Dropped python-sendfile.
  - Dropped python-nose.
  - Added testrepository.
  - Added python-testtools.
* debian/rules: Run testrepository instead of nosetets.
* debian/patches/removes-lxml-version-limitation-from-pip-requires.patch: Dropped
  no longer needed.
* debian/patches/fix-package-version-detection-when-building-doc.patch: Dropped
  no longer needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 
15
15
import json
16
16
import os
17
 
import unittest
18
17
 
19
 
import mox
20
 
from nose.plugins.attrib import attr
21
18
from oslo.config import cfg
22
19
 
23
20
from heat.common import context
26
23
from heat.openstack.common import rpc
27
24
import heat.openstack.common.rpc.common as rpc_common
28
25
from heat.common.wsgi import Request
 
26
from heat.rpc import api as rpc_api
29
27
from heat.api.aws import exception
30
28
import heat.api.cfn.v1.stacks as stacks
31
 
 
32
 
 
33
 
@attr(tag=['unit', 'api-cfn-v1-stacks', 'StackController'])
34
 
@attr(speed='fast')
35
 
class CfnStackControllerTest(unittest.TestCase):
 
29
from heat.tests.common import HeatTestCase
 
30
 
 
31
policy_path = os.path.dirname(os.path.realpath(__file__)) + "/policy/"
 
32
 
 
33
 
 
34
class CfnStackControllerTest(HeatTestCase):
36
35
    '''
37
36
    Tests the API class which acts as the WSGI controller,
38
37
    the endpoint processing API requests after they are routed
86
85
        params = {'Action': 'ListStacks'}
87
86
        dummy_req = self._dummy_GET_request(params)
88
87
        dummy_req.context.roles = ['heat_stack_user']
89
 
        self.controller.policy.policy_path = (self.policy_path +
 
88
        self.controller.policy.policy_path = (policy_path +
90
89
                                              'deny_stack_user.json')
91
90
        self.assertRaises(exception.HeatAccessDeniedError,
92
91
                          self.controller._enforce, dummy_req, 'ListStacks')
102
101
                                ).AndRaise(AttributeError)
103
102
        self.m.ReplayAll()
104
103
 
105
 
        self.controller.policy.policy_path = (self.policy_path +
 
104
        self.controller.policy.policy_path = (policy_path +
106
105
                                              'deny_stack_user.json')
107
106
        self.assertRaises(exception.HeatInternalFailureError,
108
107
                          self.controller._enforce, dummy_req, 'ListStacks')
123
122
                        u'stack_status_reason': u'Stack successfully created',
124
123
                        u'creation_time': u'2012-07-09T09:12:45Z',
125
124
                        u'stack_name': u'wordpress',
126
 
                        u'stack_status': u'CREATE_COMPLETE'}]
 
125
                        u'stack_action': u'CREATE',
 
126
                        u'stack_status': u'COMPLETE'}]
127
127
        self.m.StubOutWithMock(rpc, 'call')
128
128
        rpc.call(dummy_req.context, self.topic,
129
 
                 {'method': 'list_stacks',
 
129
                 {'namespace': None,
 
130
                  'method': 'list_stacks',
130
131
                  'args': {},
131
132
                  'version': self.api_version},
132
133
                 None).AndReturn(engine_resp)
155
156
        # heat exception type
156
157
        self.m.StubOutWithMock(rpc, 'call')
157
158
        rpc.call(dummy_req.context, self.topic,
158
 
                 {'method': 'list_stacks',
 
159
                 {'namespace': None,
 
160
                  'method': 'list_stacks',
159
161
                  'args': {},
160
162
                  'version': self.api_version},
161
163
                 None).AndRaise(rpc_common.RemoteError("AttributeError"))
176
178
        # heat exception type
177
179
        self.m.StubOutWithMock(rpc, 'call')
178
180
        rpc.call(dummy_req.context, self.topic,
179
 
                 {'method': 'list_stacks',
 
181
                 {'namespace': None,
 
182
                  'method': 'list_stacks',
180
183
                  'args': {},
181
184
                  'version': self.api_version},
182
185
                 None).AndRaise(rpc_common.RemoteError("Exception"))
218
221
                       u'creation_time': u'2012-07-09T09:12:45Z',
219
222
                       u'stack_name': u'wordpress',
220
223
                       u'notification_topics': [],
221
 
                       u'stack_status': u'CREATE_COMPLETE',
 
224
                       u'stack_action': u'CREATE',
 
225
                       u'stack_status': u'COMPLETE',
222
226
                       u'description': u'blah',
223
227
                       u'disable_rollback': 'true',
224
228
                       u'timeout_mins':60,
226
230
 
227
231
        self.m.StubOutWithMock(rpc, 'call')
228
232
        rpc.call(dummy_req.context, self.topic,
229
 
                 {'method': 'identify_stack',
 
233
                 {'namespace': None,
 
234
                  'method': 'identify_stack',
230
235
                  'args': {'stack_name': stack_name},
231
236
                  'version': self.api_version}, None).AndReturn(identity)
232
237
        rpc.call(dummy_req.context, self.topic,
233
 
                 {'method': 'show_stack',
 
238
                 {'namespace': None,
 
239
                  'method': 'show_stack',
234
240
                  'args': {'stack_identity': identity},
235
241
                  'version': self.api_version}, None).AndReturn(engine_resp)
236
242
 
305
311
                        u'creation_time': u'2012-07-09T09:12:45Z',
306
312
                        u'stack_name': u'wordpress',
307
313
                        u'notification_topics': [],
308
 
                        u'stack_status': u'CREATE_COMPLETE',
 
314
                        u'stack_action': u'CREATE',
 
315
                        u'stack_status': u'COMPLETE',
309
316
                        u'description': u'blah',
310
317
                        u'disable_rollback': 'true',
311
318
                        u'timeout_mins':60,
313
320
 
314
321
        self.m.StubOutWithMock(rpc, 'call')
315
322
        rpc.call(dummy_req.context, self.topic,
316
 
                 {'method': 'show_stack',
 
323
                 {'namespace': None,
 
324
                  'method': 'show_stack',
317
325
                  'args': {'stack_identity': identity},
318
326
                  'version': self.api_version}, None).AndReturn(engine_resp)
319
327
 
368
376
 
369
377
        self.m.StubOutWithMock(rpc, 'call')
370
378
        rpc.call(dummy_req.context, self.topic,
371
 
                 {'method': 'show_stack',
 
379
                 {'namespace': None,
 
380
                  'method': 'show_stack',
372
381
                  'args': {'stack_identity': identity},
373
382
                  'version': self.api_version},
374
383
                 None).AndRaise(rpc_common.RemoteError("InvalidTenant"))
390
399
        # heat exception type
391
400
        self.m.StubOutWithMock(rpc, 'call')
392
401
        rpc.call(dummy_req.context, self.topic,
393
 
                 {'method': 'identify_stack',
 
402
                 {'namespace': None,
 
403
                  'method': 'identify_stack',
394
404
                  'args': {'stack_name': stack_name},
395
405
                  'version': self.api_version}, None).AndReturn(identity)
396
406
        rpc.call(dummy_req.context, self.topic,
397
 
                 {'method': 'show_stack',
 
407
                 {'namespace': None,
 
408
                  'method': 'show_stack',
398
409
                  'args': {'stack_identity': identity},
399
410
                  'version': self.api_version}, None
400
411
                 ).AndRaise(rpc_common.RemoteError("AttributeError"))
415
426
        # heat exception type
416
427
        self.m.StubOutWithMock(rpc, 'call')
417
428
        rpc.call(dummy_req.context, self.topic,
418
 
                 {'method': 'identify_stack',
 
429
                 {'namespace': None,
 
430
                  'method': 'identify_stack',
419
431
                  'args': {'stack_name': stack_name},
420
432
                  'version': self.api_version}, None
421
433
                 ).AndRaise(rpc_common.RemoteError("StackNotFound"))
428
440
        self.m.VerifyAll()
429
441
 
430
442
    def test_get_template_int_body(self):
431
 
        ''' Test the internal _get_template function '''
 
443
        '''Test the internal _get_template function.'''
432
444
        params = {'TemplateBody': "abcdef"}
433
445
        dummy_req = self._dummy_GET_request(params)
434
446
        result = self.controller._get_template(dummy_req)
435
447
        expected = "abcdef"
436
448
        self.assertEqual(result, expected)
437
449
 
438
 
    # TODO : test the _get_template TemplateUrl case
 
450
    # TODO(shardy) : test the _get_template TemplateUrl case
439
451
 
440
452
    def test_create(self):
441
453
        # Format a dummy request
460
472
 
461
473
        self.m.StubOutWithMock(rpc, 'call')
462
474
        rpc.call(dummy_req.context, self.topic,
463
 
                 {'method': 'create_stack',
 
475
                 {'namespace': None,
 
476
                  'method': 'create_stack',
464
477
                  'args': {'stack_name': stack_name,
465
478
                           'template': template,
466
479
                           'params': engine_parms,
 
480
                           'files': {},
467
481
                           'args': engine_args},
468
482
                  'version': self.api_version}, None).AndReturn(engine_resp)
469
483
 
522
536
        self.m.StubOutWithMock(rpc, 'call')
523
537
 
524
538
        rpc.call(dummy_req.context, self.topic,
525
 
                 {'method': 'create_stack',
 
539
                 {'namespace': None,
 
540
                  'method': 'create_stack',
526
541
                  'args': {'stack_name': stack_name,
527
542
                           'template': template,
528
543
                           'params': engine_parms,
 
544
                           'files': {},
529
545
                           'args': engine_args},
530
546
                  'version': self.api_version}, None
531
547
                 ).AndRaise(rpc_common.RemoteError("AttributeError"))
 
548
        rpc.call(dummy_req.context, self.topic,
 
549
                 {'namespace': None,
 
550
                  'method': 'create_stack',
 
551
                  'args': {'stack_name': stack_name,
 
552
                           'template': template,
 
553
                           'params': engine_parms,
 
554
                           'files': {},
 
555
                           'args': engine_args},
 
556
                  'version': self.api_version}, None
 
557
                 ).AndRaise(rpc_common.RemoteError("UnknownUserParameter"))
 
558
        rpc.call(dummy_req.context, self.topic,
 
559
                 {'namespace': None,
 
560
                  'method': 'create_stack',
 
561
                  'args': {'stack_name': stack_name,
 
562
                           'template': template,
 
563
                           'params': engine_parms,
 
564
                           'files': {},
 
565
                           'args': engine_args},
 
566
                  'version': self.api_version}, None
 
567
                 ).AndRaise(rpc_common.RemoteError("UserParameterMissing"))
532
568
 
533
569
        self.m.ReplayAll()
534
570
 
536
572
 
537
573
        self.assertEqual(type(result),
538
574
                         exception.HeatInvalidParameterValueError)
 
575
 
 
576
        result = self.controller.create(dummy_req)
 
577
 
 
578
        self.assertEqual(type(result),
 
579
                         exception.HeatInvalidParameterValueError)
 
580
 
 
581
        result = self.controller.create(dummy_req)
 
582
 
 
583
        self.assertEqual(type(result),
 
584
                         exception.HeatInvalidParameterValueError)
 
585
 
539
586
        self.m.VerifyAll()
540
587
 
541
588
    def test_create_err_exists(self):
557
604
        self.m.StubOutWithMock(rpc, 'call')
558
605
 
559
606
        rpc.call(dummy_req.context, self.topic,
560
 
                 {'method': 'create_stack',
 
607
                 {'namespace': None,
 
608
                  'method': 'create_stack',
561
609
                  'args': {'stack_name': stack_name,
562
610
                           'template': template,
563
611
                           'params': engine_parms,
 
612
                           'files': {},
564
613
                           'args': engine_args},
565
614
                  'version': self.api_version}, None
566
615
                 ).AndRaise(rpc_common.RemoteError("StackExists"))
570
619
        result = self.controller.create(dummy_req)
571
620
 
572
621
        self.assertEqual(type(result),
573
 
                         exception.HeatInvalidParameterValueError)
 
622
                         exception.AlreadyExistsError)
574
623
        self.m.VerifyAll()
575
624
 
576
625
    def test_create_err_engine(self):
591
640
        self.m.StubOutWithMock(rpc, 'call')
592
641
 
593
642
        rpc.call(dummy_req.context, self.topic,
594
 
                 {'method': 'create_stack',
 
643
                 {'namespace': None,
 
644
                  'method': 'create_stack',
595
645
                  'args': {'stack_name': stack_name,
596
646
                  'template': template,
597
647
                  'params': engine_parms,
 
648
                  'files': {},
598
649
                  'args': engine_args},
599
650
                  'version': self.api_version}, None).AndRaise(
600
651
                      rpc_common.RemoteError(
627
678
 
628
679
        self.m.StubOutWithMock(rpc, 'call')
629
680
        rpc.call(dummy_req.context, self.topic,
630
 
                 {'method': 'identify_stack',
 
681
                 {'namespace': None,
 
682
                  'method': 'identify_stack',
631
683
                  'args': {'stack_name': stack_name},
632
684
                  'version': self.api_version}, None).AndReturn(identity)
633
685
 
634
686
        rpc.call(dummy_req.context, self.topic,
635
 
                 {'method': 'update_stack',
 
687
                 {'namespace': None,
 
688
                  'method': 'update_stack',
636
689
                  'args': {'stack_identity': identity,
637
690
                           'template': template,
638
691
                           'params': engine_parms,
 
692
                           'files': {},
639
693
                           'args': engine_args},
640
694
                  'version': self.api_version},
641
695
                 None).AndReturn(identity)
669
723
        # heat exception type
670
724
        self.m.StubOutWithMock(rpc, 'call')
671
725
        rpc.call(dummy_req.context, self.topic,
672
 
                 {'method': 'identify_stack',
 
726
                 {'namespace': None,
 
727
                  'method': 'identify_stack',
673
728
                  'args': {'stack_name': stack_name},
674
729
                  'version': self.api_version}, None
675
730
                 ).AndRaise(rpc_common.RemoteError("StackNotFound"))
698
753
 
699
754
        self.m.StubOutWithMock(rpc, 'call')
700
755
        rpc.call(dummy_req.context, self.topic,
701
 
                 {'method': 'identify_stack',
 
756
                 {'namespace': None,
 
757
                  'method': 'identify_stack',
702
758
                  'args': {'stack_name': stack_name},
703
759
                  'version': self.api_version}, None).AndReturn(identity)
704
760
        rpc.call(dummy_req.context, self.topic,
705
 
                 {'method': 'get_template',
 
761
                 {'namespace': None,
 
762
                  'method': 'get_template',
706
763
                  'args': {'stack_identity': identity},
707
764
                  'version': self.api_version}, None).AndReturn(engine_resp)
708
765
 
728
785
        # heat exception type
729
786
        self.m.StubOutWithMock(rpc, 'call')
730
787
        rpc.call(dummy_req.context, self.topic,
731
 
                 {'method': 'identify_stack',
 
788
                 {'namespace': None,
 
789
                  'method': 'identify_stack',
732
790
                  'args': {'stack_name': stack_name},
733
791
                  'version': self.api_version}, None).AndReturn(identity)
734
792
        rpc.call(dummy_req.context, self.topic,
735
 
                 {'method': 'get_template',
 
793
                 {'namespace': None,
 
794
                  'method': 'get_template',
736
795
                  'args': {'stack_identity': identity},
737
796
                  'version': self.api_version}, None
738
797
                 ).AndRaise(rpc_common.RemoteError("AttributeError"))
754
813
        # heat exception type
755
814
        self.m.StubOutWithMock(rpc, 'call')
756
815
        rpc.call(dummy_req.context, self.topic,
757
 
                 {'method': 'identify_stack',
 
816
                 {'namespace': None,
 
817
                  'method': 'identify_stack',
758
818
                  'args': {'stack_name': stack_name},
759
819
                  'version': self.api_version}, None
760
820
                 ).AndRaise(rpc_common.RemoteError("StackNotFound"))
779
839
 
780
840
        self.m.StubOutWithMock(rpc, 'call')
781
841
        rpc.call(dummy_req.context, self.topic,
782
 
                 {'method': 'identify_stack',
 
842
                 {'namespace': None,
 
843
                  'method': 'identify_stack',
783
844
                  'args': {'stack_name': stack_name},
784
845
                  'version': self.api_version}, None).AndReturn(identity)
785
846
        rpc.call(dummy_req.context, self.topic,
786
 
                 {'method': 'get_template',
 
847
                 {'namespace': None,
 
848
                  'method': 'get_template',
787
849
                  'args': {'stack_identity': identity},
788
850
                  'version': self.api_version}, None).AndReturn(engine_resp)
789
851
 
825
887
        # Stub out the RPC call to the engine with a pre-canned response
826
888
        self.m.StubOutWithMock(rpc, 'call')
827
889
        rpc.call(dummy_req.context, self.topic,
828
 
                 {'method': 'identify_stack',
 
890
                 {'namespace': None,
 
891
                  'method': 'identify_stack',
829
892
                  'args': {'stack_name': stack_name},
830
893
                  'version': self.api_version}, None).AndReturn(identity)
831
894
        # Engine returns None when delete successful
832
895
        rpc.call(dummy_req.context, self.topic,
833
 
                 {'method': 'delete_stack',
 
896
                 {'namespace': None,
 
897
                  'method': 'delete_stack',
834
898
                  'args': {'stack_identity': identity},
835
899
                  'version': self.api_version}, None).AndReturn(None)
836
900
 
852
916
        # Stub out the RPC call to the engine with a pre-canned response
853
917
        self.m.StubOutWithMock(rpc, 'call')
854
918
        rpc.call(dummy_req.context, self.topic,
855
 
                 {'method': 'identify_stack',
 
919
                 {'namespace': None,
 
920
                  'method': 'identify_stack',
856
921
                  'args': {'stack_name': stack_name},
857
922
                  'version': self.api_version}, None).AndReturn(identity)
858
923
 
859
924
        # Insert an engine RPC error and ensure we map correctly to the
860
925
        # heat exception type
861
926
        rpc.call(dummy_req.context, self.topic,
862
 
                 {'method': 'delete_stack',
 
927
                 {'namespace': None,
 
928
                  'method': 'delete_stack',
863
929
                  'args': {'stack_identity': identity},
864
930
                  'version': self.api_version}, None
865
931
                 ).AndRaise(rpc_common.RemoteError("AttributeError"))
881
947
        # heat exception type
882
948
        self.m.StubOutWithMock(rpc, 'call')
883
949
        rpc.call(dummy_req.context, self.topic,
884
 
                 {'method': 'identify_stack',
 
950
                 {'namespace': None,
 
951
                  'method': 'identify_stack',
885
952
                  'args': {'stack_name': stack_name},
886
953
                  'version': self.api_version}, None
887
954
                 ).AndRaise(rpc_common.RemoteError("StackNotFound"))
914
981
                         u'stack_name': u'wordpress',
915
982
                         u'stack_id': u'6',
916
983
                         u'path': u'/resources/WikiDatabase/events/42'},
 
984
                        u'resource_action': u'TEST',
917
985
                        u'resource_status': u'IN_PROGRESS',
918
986
                        u'physical_resource_id': None,
919
987
                        u'resource_properties': {u'UserData': u'blah'},
921
989
 
922
990
        self.m.StubOutWithMock(rpc, 'call')
923
991
        rpc.call(dummy_req.context, self.topic,
924
 
                 {'method': 'identify_stack',
 
992
                 {'namespace': None,
 
993
                  'method': 'identify_stack',
925
994
                  'args': {'stack_name': stack_name},
926
995
                  'version': self.api_version}, None).AndReturn(identity)
927
996
        rpc.call(dummy_req.context, self.topic,
928
 
                 {'method': 'list_events',
 
997
                 {'namespace': None,
 
998
                  'method': 'list_events',
929
999
                  'args': {'stack_identity': identity},
930
1000
                  'version': self.api_version}, None).AndReturn(engine_resp)
931
1001
 
938
1008
                     {'StackEvents':
939
1009
                      [{'EventId': u'42',
940
1010
                        'StackId': u'arn:openstack:heat::t:stacks/wordpress/6',
941
 
                        'ResourceStatus': u'IN_PROGRESS',
 
1011
                        'ResourceStatus': u'TEST_IN_PROGRESS',
942
1012
                        'ResourceType': u'AWS::EC2::Instance',
943
1013
                        'Timestamp': u'2012-07-23T13:05:39Z',
944
1014
                        'StackName': u'wordpress',
961
1031
        # heat exception type
962
1032
        self.m.StubOutWithMock(rpc, 'call')
963
1033
        rpc.call(dummy_req.context, self.topic,
964
 
                 {'method': 'identify_stack',
 
1034
                 {'namespace': None,
 
1035
                  'method': 'identify_stack',
965
1036
                  'args': {'stack_name': stack_name},
966
1037
                  'version': self.api_version}, None).AndReturn(identity)
967
1038
        rpc.call(dummy_req.context, self.topic,
968
 
                 {'method': 'list_events',
 
1039
                 {'namespace': None,
 
1040
                  'method': 'list_events',
969
1041
                  'args': {'stack_identity': identity},
970
1042
                  'version': self.api_version}, None
971
1043
                 ).AndRaise(rpc_common.RemoteError("Exception"))
986
1058
        # heat exception type
987
1059
        self.m.StubOutWithMock(rpc, 'call')
988
1060
        rpc.call(dummy_req.context, self.topic,
989
 
                 {'method': 'identify_stack',
 
1061
                 {'namespace': None,
 
1062
                  'method': 'identify_stack',
990
1063
                  'args': {'stack_name': stack_name},
991
1064
                  'version': self.api_version}, None
992
1065
                 ).AndRaise(rpc_common.RemoteError("StackNotFound"))
1023
1096
                                           u'stack_name': u'wordpress',
1024
1097
                                           u'stack_id': u'6',
1025
1098
                                           u'path': u''},
1026
 
                       u'resource_status': u'CREATE_COMPLETE',
 
1099
                       u'resource_action': u'CREATE',
 
1100
                       u'resource_status': u'COMPLETE',
1027
1101
                       u'physical_resource_id':
1028
1102
                       u'a3455d8c-9f88-404d-a85b-5315293e67de',
1029
1103
                       u'resource_type': u'AWS::EC2::Instance',
1031
1105
 
1032
1106
        self.m.StubOutWithMock(rpc, 'call')
1033
1107
        rpc.call(dummy_req.context, self.topic,
1034
 
                 {'method': 'identify_stack',
 
1108
                 {'namespace': None,
 
1109
                  'method': 'identify_stack',
1035
1110
                  'args': {'stack_name': stack_name},
1036
1111
                  'version': self.api_version}, None).AndReturn(identity)
1037
1112
        args = {
1039
1114
            'resource_name': dummy_req.params.get('LogicalResourceId'),
1040
1115
        }
1041
1116
        rpc.call(dummy_req.context, self.topic,
1042
 
                 {'method': 'describe_stack_resource',
 
1117
                 {'namespace': None,
 
1118
                  'method': 'describe_stack_resource',
1043
1119
                  'args': args,
1044
1120
                  'version': self.api_version}, None).AndReturn(engine_resp)
1045
1121
 
1077
1153
        # Stub out the RPC call to the engine with a pre-canned response
1078
1154
        self.m.StubOutWithMock(rpc, 'call')
1079
1155
        rpc.call(dummy_req.context, self.topic,
1080
 
                 {'method': 'identify_stack',
 
1156
                 {'namespace': None,
 
1157
                  'method': 'identify_stack',
1081
1158
                  'args': {'stack_name': stack_name},
1082
1159
                  'version': self.api_version},
1083
1160
                 None).AndRaise(rpc_common.RemoteError("StackNotFound"))
1101
1178
        # Stub out the RPC call to the engine with a pre-canned response
1102
1179
        self.m.StubOutWithMock(rpc, 'call')
1103
1180
        rpc.call(dummy_req.context, self.topic,
1104
 
                 {'method': 'identify_stack',
 
1181
                 {'namespace': None,
 
1182
                  'method': 'identify_stack',
1105
1183
                  'args': {'stack_name': stack_name},
1106
1184
                  'version': self.api_version}, None).AndReturn(identity)
1107
1185
        args = {
1109
1187
            'resource_name': dummy_req.params.get('LogicalResourceId'),
1110
1188
        }
1111
1189
        rpc.call(dummy_req.context, self.topic,
1112
 
                 {'method': 'describe_stack_resource',
 
1190
                 {'namespace': None,
 
1191
                  'method': 'describe_stack_resource',
1113
1192
                  'args': args,
1114
1193
                  'version': self.api_version},
1115
1194
                 None).AndRaise(rpc_common.RemoteError("ResourceNotFound"))
1146
1225
                                            u'stack_name': u'wordpress',
1147
1226
                                            u'stack_id': u'6',
1148
1227
                                            u'path': u''},
1149
 
                        u'resource_status': u'CREATE_COMPLETE',
 
1228
                        u'resource_action': u'CREATE',
 
1229
                        u'resource_status': u'COMPLETE',
1150
1230
                        u'physical_resource_id':
1151
1231
                        u'a3455d8c-9f88-404d-a85b-5315293e67de',
1152
1232
                        u'resource_type': u'AWS::EC2::Instance',
1154
1234
 
1155
1235
        self.m.StubOutWithMock(rpc, 'call')
1156
1236
        rpc.call(dummy_req.context, self.topic,
1157
 
                 {'method': 'identify_stack',
 
1237
                 {'namespace': None,
 
1238
                  'method': 'identify_stack',
1158
1239
                  'args': {'stack_name': stack_name},
1159
1240
                  'version': self.api_version}, None).AndReturn(identity)
1160
1241
        args = {
1162
1243
            'resource_name': dummy_req.params.get('LogicalResourceId'),
1163
1244
        }
1164
1245
        rpc.call(dummy_req.context, self.topic,
1165
 
                 {'method': 'describe_stack_resources',
 
1246
                 {'namespace': None,
 
1247
                  'method': 'describe_stack_resources',
1166
1248
                  'args': args,
1167
1249
                  'version': self.api_version}, None).AndReturn(engine_resp)
1168
1250
 
1198
1280
        # heat exception type
1199
1281
        self.m.StubOutWithMock(rpc, 'call')
1200
1282
        rpc.call(dummy_req.context, self.topic,
1201
 
                 {'method': 'identify_stack',
 
1283
                 {'namespace': None,
 
1284
                  'method': 'identify_stack',
1202
1285
                  'args': {'stack_name': stack_name},
1203
1286
                  'version': self.api_version}, None
1204
1287
                 ).AndRaise(rpc_common.RemoteError("StackNotFound"))
1235
1318
                                            u'stack_name': u'wordpress',
1236
1319
                                            u'stack_id': u'6',
1237
1320
                                            u'path': u''},
1238
 
                        u'resource_status': u'CREATE_COMPLETE',
 
1321
                        u'resource_action': u'CREATE',
 
1322
                        u'resource_status': u'COMPLETE',
1239
1323
                        u'physical_resource_id':
1240
1324
                        u'a3455d8c-9f88-404d-a85b-5315293e67de',
1241
1325
                        u'resource_type': u'AWS::EC2::Instance',
1243
1327
 
1244
1328
        self.m.StubOutWithMock(rpc, 'call')
1245
1329
        rpc.call(dummy_req.context, self.topic,
1246
 
                 {'method': 'find_physical_resource',
 
1330
                 {'namespace': None,
 
1331
                  'method': 'find_physical_resource',
1247
1332
                  'args': {'physical_resource_id':
1248
1333
                           'a3455d8c-9f88-404d-a85b-5315293e67de'},
1249
1334
                  'version': self.api_version}, None).AndReturn(identity)
1252
1337
            'resource_name': dummy_req.params.get('LogicalResourceId'),
1253
1338
        }
1254
1339
        rpc.call(dummy_req.context, self.topic,
1255
 
                 {'method': 'describe_stack_resources',
 
1340
                 {'namespace': None,
 
1341
                  'method': 'describe_stack_resources',
1256
1342
                  'args': args,
1257
1343
                  'version': self.api_version}, None).AndReturn(engine_resp)
1258
1344
 
1289
1375
        # Stub out the RPC call to the engine with a pre-canned response
1290
1376
        self.m.StubOutWithMock(rpc, 'call')
1291
1377
        rpc.call(dummy_req.context, self.topic,
1292
 
                 {'method': 'find_physical_resource',
 
1378
                 {'namespace': None,
 
1379
                  'method': 'find_physical_resource',
1293
1380
                  'args': {'physical_resource_id':
1294
1381
                           'aaaaaaaa-9f88-404d-cccc-ffffffffffff'},
1295
1382
                  'version': self.api_version},
1340
1427
                                            u'stack_name': u'wordpress',
1341
1428
                                            u'stack_id': u'6',
1342
1429
                                            u'path': u''},
1343
 
                        u'resource_status': u'CREATE_COMPLETE',
 
1430
                        u'resource_action': u'CREATE',
 
1431
                        u'resource_status': u'COMPLETE',
1344
1432
                        u'physical_resource_id':
1345
1433
                        u'a3455d8c-9f88-404d-a85b-5315293e67de',
1346
1434
                        u'resource_type': u'AWS::EC2::Instance'}]
1347
1435
 
1348
1436
        self.m.StubOutWithMock(rpc, 'call')
1349
1437
        rpc.call(dummy_req.context, self.topic,
1350
 
                 {'method': 'identify_stack',
 
1438
                 {'namespace': None,
 
1439
                  'method': 'identify_stack',
1351
1440
                  'args': {'stack_name': stack_name},
1352
1441
                  'version': self.api_version}, None).AndReturn(identity)
1353
1442
        rpc.call(dummy_req.context, self.topic,
1354
 
                 {'method': 'list_stack_resources',
 
1443
                 {'namespace': None,
 
1444
                  'method': 'list_stack_resources',
1355
1445
                 'args': {'stack_identity': identity},
1356
1446
                 'version': self.api_version}, None).AndReturn(engine_resp)
1357
1447
 
1382
1472
        # heat exception type
1383
1473
        self.m.StubOutWithMock(rpc, 'call')
1384
1474
        rpc.call(dummy_req.context, self.topic,
1385
 
                 {'method': 'identify_stack',
 
1475
                 {'namespace': None,
 
1476
                  'method': 'identify_stack',
1386
1477
                  'args': {'stack_name': stack_name},
1387
1478
                  'version': self.api_version}, None
1388
1479
                 ).AndRaise(rpc_common.RemoteError("StackNotFound"))
1395
1486
        self.m.VerifyAll()
1396
1487
 
1397
1488
    def setUp(self):
1398
 
        self.maxDiff = None
1399
 
        self.m = mox.Mox()
 
1489
        super(CfnStackControllerTest, self).setUp()
1400
1490
 
1401
 
        self.path = os.path.dirname(os.path.realpath(__file__))
1402
 
        self.policy_path = self.path + "/policy/"
1403
1491
        opts = [
1404
 
            cfg.StrOpt('config_dir', default=self.policy_path),
 
1492
            cfg.StrOpt('config_dir', default=policy_path),
1405
1493
            cfg.StrOpt('config_file', default='foo'),
1406
1494
            cfg.StrOpt('project', default='heat'),
1407
1495
        ]
1408
1496
        cfg.CONF.register_opts(opts)
1409
 
        cfg.CONF.set_default('engine_topic', 'engine')
1410
1497
        cfg.CONF.set_default('host', 'host')
1411
 
        self.topic = '%s.%s' % (cfg.CONF.engine_topic, cfg.CONF.host)
 
1498
        self.topic = rpc_api.ENGINE_TOPIC
1412
1499
        self.api_version = '1.0'
1413
1500
 
1414
1501
        # Create WSGI controller instance
1416
1503
            bind_port = 8000
1417
1504
        cfgopts = DummyConfig()
1418
1505
        self.controller = stacks.StackController(options=cfgopts)
1419
 
        print "setup complete"
1420
 
 
1421
 
    def tearDown(self):
1422
 
        self.m.UnsetStubs()
1423
 
        print "teardown complete"