mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Add tests for security group model and collection.
This commit is contained in:
parent
d6b93f6602
commit
2ac385bbf1
2 changed files with 41 additions and 0 deletions
36
tests/hp/models/compute/security_group_tests.rb
Normal file
36
tests/hp/models/compute/security_group_tests.rb
Normal file
|
@ -0,0 +1,36 @@
|
|||
Shindo.tests("Fog::Compute[:hp] | security_group", ['hp']) do
|
||||
|
||||
model_tests(Fog::Compute[:hp].security_groups, {:name => 'foggroupname', :description => 'foggroupdescription'}, true)
|
||||
|
||||
tests("a group with trailing whitespace") do
|
||||
@group = Fog::Compute[:hp].security_groups.create(:name => "foggroup with spaces ", :description => " fog group desc ")
|
||||
|
||||
test("name is correct") do
|
||||
@group.name == "foggroup with spaces "
|
||||
end
|
||||
|
||||
test("description is correct") do
|
||||
@group.description == " fog group desc "
|
||||
end
|
||||
|
||||
@other_group = Fog::Compute[:hp].security_groups.create(:name => 'other group', :description => 'another group')
|
||||
|
||||
test("authorize access by another security group") do
|
||||
sgrule = @group.create_rule(80..80, "tcp", nil, @other_group.id)
|
||||
@sg_rule_id = sgrule.body['security_group_rule']['id']
|
||||
@group.reload
|
||||
s = @group.rules.select {|r| r['id'] == @sg_rule_id unless r.nil?}
|
||||
s[0]['id'] == @sg_rule_id
|
||||
end
|
||||
|
||||
test("revoke access from another security group") do
|
||||
@group.delete_rule(@sg_rule_id)
|
||||
@group.reload
|
||||
s = @group.rules.select {|r| r['id'] == @sg_rule_id unless r.nil?}
|
||||
s.empty?
|
||||
end
|
||||
|
||||
@other_group.destroy
|
||||
@group.destroy
|
||||
end
|
||||
end
|
5
tests/hp/models/compute/security_groups_tests.rb
Normal file
5
tests/hp/models/compute/security_groups_tests.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
Shindo.tests("Fog::Compute[:hp] | security_groups", ['hp']) do
|
||||
|
||||
collection_tests(Fog::Compute[:hp].security_groups, {:name => 'foggroupname', :description => 'foggroupdescription'}, true)
|
||||
|
||||
end
|
Loading…
Add table
Reference in a new issue