@@ -5,119 +5,117 @@ var assert = require('assert');
55var client = helpers . createClient ( 'amazon' , 'compute' ) ;
66
77// Tests
8- var suite = vows . describe ( '[Amazon Client] SecurityGroup management' ) ;
9-
10- suite . addBatch ( {
11- 'add SecurityGroup' : {
12- topic : function ( ) {
13- client . addGroup ( {
14- name : 'unit test' ,
15- description : 'unit test'
16- } , this . callback )
17- } ,
18- 'should succeed' : function ( err , data ) {
19- assert . isNull ( err ) ;
20- assert . isTrue ( data ) ;
21- }
8+ var suite = vows . describe ( 'pkgcloud/amazon/groups' ) . addBatch ( {
9+ 'add SecurityGroup' : {
10+ topic : function ( ) {
11+ client . addGroup ( {
12+ name : 'unit test' ,
13+ description : 'unit test'
14+ } , this . callback )
2215 } ,
23- 'destroy SecurityGroup' : {
24- topic : function ( ) {
25- client . destroyGroup ( 'unit test' , this . callback ) ;
26- } ,
27- 'should succeed' : function ( err , data ) {
28- assert . isNull ( err ) ;
29- assert . isTrue ( data ) ;
30- }
16+ 'should succeed' : function ( err , data ) {
17+ assert . isNull ( err ) ;
18+ assert . isTrue ( data ) ;
19+ }
20+ } ,
21+ 'destroy SecurityGroup' : {
22+ topic : function ( ) {
23+ client . destroyGroup ( 'unit test' , this . callback ) ;
3124 } ,
32- 'list SecurityGroups' : {
33- topic : function ( ) {
34- client . listGroups ( this . callback ) ;
35- } ,
36- 'should succeed' : function ( err , data ) {
37- assert . isNull ( err ) ;
38- assert . isArray ( data ) ;
39- }
25+ 'should succeed' : function ( err , data ) {
26+ assert . isNull ( err ) ;
27+ assert . isTrue ( data ) ;
28+ }
29+ } ,
30+ 'list SecurityGroups' : {
31+ topic : function ( ) {
32+ client . listGroups ( this . callback ) ;
4033 } ,
41- 'get SecurityGroup' : {
42- topic : function ( ) {
43- client . getGroup ( 'unit test' , this . callback ) ;
44- } ,
45- 'should succeed' : function ( err , data ) {
46- assert . isNull ( err ) ;
47- // TODO
48- }
34+ 'should succeed' : function ( err , data ) {
35+ assert . isNull ( err ) ;
36+ assert . isArray ( data ) ;
37+ }
38+ } ,
39+ 'get SecurityGroup' : {
40+ topic : function ( ) {
41+ client . getGroup ( 'unit test' , this . callback ) ;
4942 } ,
50- 'add Rules' : {
51- topic : function ( ) {
52- client . addRules ( {
53- name : 'unit test' ,
54- rules : {
55- 'IpPermissions.1.IpProtocol' : 'tcp' ,
56- 'IpPermissions.1.Groups.1.GroupName' : 'unit test' ,
57- 'IpPermissions.1.FromPort' : 0 ,
58- 'IpPermissions.1.ToPort' : 65535
59- }
60- } , this . callback ) ;
61- } ,
62- 'should succeed' : function ( err , data ) {
63- assert . isNull ( err ) ;
64- assert . isTrue ( data ) ;
43+ 'should succeed' : function ( err , data ) {
44+ assert . isNull ( err ) ;
45+ // TODO
46+ }
47+ } ,
48+ 'add Rules' : {
49+ topic : function ( ) {
50+ client . addRules ( {
51+ name : 'unit test' ,
52+ rules : {
53+ 'IpPermissions.1.IpProtocol' : 'tcp' ,
54+ 'IpPermissions.1.Groups.1.GroupName' : 'unit test' ,
55+ 'IpPermissions.1.FromPort' : 0 ,
56+ 'IpPermissions.1.ToPort' : 65535
6557 }
58+ } , this . callback ) ;
6659 } ,
67- 'destroy Rules' : {
68- topic : function ( ) {
69- client . delRules ( {
70- name : 'unit test' ,
71- rules : {
72- 'IpPermissions.1.IpProtocol' : 'tcp' ,
73- 'IpPermissions.1.Groups.1.GroupName' : 'unit test' ,
74- 'IpPermissions.1.FromPort' : 0 ,
75- 'IpPermissions.1.ToPort' : 65535
76- }
77- } , this . callback ) ;
78- } ,
79- 'should succeed' : function ( err , data ) {
80- assert . isNull ( err ) ;
81- assert . isTrue ( data ) ;
60+ 'should succeed' : function ( err , data ) {
61+ assert . isNull ( err ) ;
62+ assert . isTrue ( data ) ;
63+ }
64+ } ,
65+ 'destroy Rules' : {
66+ topic : function ( ) {
67+ client . delRules ( {
68+ name : 'unit test' ,
69+ rules : {
70+ 'IpPermissions.1.IpProtocol' : 'tcp' ,
71+ 'IpPermissions.1.Groups.1.GroupName' : 'unit test' ,
72+ 'IpPermissions.1.FromPort' : 0 ,
73+ 'IpPermissions.1.ToPort' : 65535
8274 }
75+ } , this . callback ) ;
76+ } ,
77+ 'should succeed' : function ( err , data ) {
78+ assert . isNull ( err ) ;
79+ assert . isTrue ( data ) ;
8380 }
81+ }
8482} ) ;
8583
8684
8785// Mock API answers
8886var nock = require ( 'nock' ) ;
8987nock ( 'https://' + client . serversUrl )
90- . filteringRequestBody ( helpers . authFilter )
91- . post ( '/?Action=CreateSecurityGroup' , {
92- GroupDescription : 'unit test' ,
93- GroupName : 'unit test'
94- } )
95- . reply ( 200 , helpers . loadFixture ( 'amazon/add-group.xml' ) , { } )
96- . post ( '/?Action=DeleteSecurityGroup' , {
97- GroupName : 'unit test'
98- } )
99- . reply ( 200 , helpers . loadFixture ( 'amazon/destroy-group.xml' , { } ) )
100- . post ( '/?Action=DescribeSecurityGroups' , { } )
101- . reply ( 200 , helpers . loadFixture ( 'amazon/list-groups.xml' ) , { } )
102- . post ( '/?Action=DescribeSecurityGroups' , {
103- 'GroupName.1' : 'unit test'
104- } )
105- . reply ( 200 , helpers . loadFixture ( 'amazon/list-group.xml' ) , { } )
106- . post ( '/?Action=AuthorizeSecurityGroupIngress' , {
107- GroupName : 'unit test' ,
108- 'IpPermissions.1.FromPort' : '0' ,
109- 'IpPermissions.1.Groups.1.GroupName' : 'unit test' ,
110- 'IpPermissions.1.IpProtocol' : 'tcp' ,
111- 'IpPermissions.1.ToPort' : '65535'
112- } )
113- . reply ( 200 , helpers . loadFixture ( 'amazon/add-rules.xml' ) , { } )
114- . post ( '/?Action=RevokeSecurityGroupIngress' , {
115- GroupName : 'unit test' ,
116- 'IpPermissions.1.FromPort' : '0' ,
117- 'IpPermissions.1.Groups.1.GroupName' : 'unit test' ,
118- 'IpPermissions.1.IpProtocol' : 'tcp' ,
119- 'IpPermissions.1.ToPort' : '65535'
120- } )
121- . reply ( 200 , helpers . loadFixture ( 'amazon/destroy-rules.xml' ) , { } )
88+ . filteringRequestBody ( helpers . authFilter )
89+ . post ( '/?Action=CreateSecurityGroup' , {
90+ GroupDescription : 'unit test' ,
91+ GroupName : 'unit test'
92+ } )
93+ . reply ( 200 , helpers . loadFixture ( 'amazon/add-group.xml' ) , { } )
94+ . post ( '/?Action=DeleteSecurityGroup' , {
95+ GroupName : 'unit test'
96+ } )
97+ . reply ( 200 , helpers . loadFixture ( 'amazon/destroy-group.xml' , { } ) )
98+ . post ( '/?Action=DescribeSecurityGroups' , { } )
99+ . reply ( 200 , helpers . loadFixture ( 'amazon/list-groups.xml' ) , { } )
100+ . post ( '/?Action=DescribeSecurityGroups' , {
101+ 'GroupName.1' : 'unit test'
102+ } )
103+ . reply ( 200 , helpers . loadFixture ( 'amazon/list-group.xml' ) , { } )
104+ . post ( '/?Action=AuthorizeSecurityGroupIngress' , {
105+ GroupName : 'unit test' ,
106+ 'IpPermissions.1.FromPort' : '0' ,
107+ 'IpPermissions.1.Groups.1.GroupName' : 'unit test' ,
108+ 'IpPermissions.1.IpProtocol' : 'tcp' ,
109+ 'IpPermissions.1.ToPort' : '65535'
110+ } )
111+ . reply ( 200 , helpers . loadFixture ( 'amazon/add-rules.xml' ) , { } )
112+ . post ( '/?Action=RevokeSecurityGroupIngress' , {
113+ GroupName : 'unit test' ,
114+ 'IpPermissions.1.FromPort' : '0' ,
115+ 'IpPermissions.1.Groups.1.GroupName' : 'unit test' ,
116+ 'IpPermissions.1.IpProtocol' : 'tcp' ,
117+ 'IpPermissions.1.ToPort' : '65535'
118+ } )
119+ . reply ( 200 , helpers . loadFixture ( 'amazon/destroy-rules.xml' ) , { } )
122120
123121suite . export ( module ) ;
0 commit comments