Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add case for testing service annotation ServiceAnnotationAllowedServiceTag #199

Merged
merged 1 commit into from
Jul 27, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions tests/e2e/network/network_security_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,29 @@ var _ = FDescribe("Network security group", func() {
ipList := []string{ip1, ip2}
Expect(validateSharedSecurityRuleExists(nsg, ipList, port)).To(BeTrue(), "Security rule for service %s not exists", serviceName)
})

It("can set source IP prefixes automatically accroding to corresponding service tag", func() {
By("Creating service and wait it to expose")
annotation := map[string]string{
azure.ServiceAnnotationAllowedServiceTag: "AzureCloud",
}
_, err := createAndWaitServiceExposure(cs, ns.Name, serviceName, annotation, labels, ports)
Expect(err).NotTo(HaveOccurred())

By("Validating if the corresponding IP prefix existing in nsg")
nsg, err := azureTestClient.GetClusterSecurityGroup()
Expect(err).NotTo(HaveOccurred())

rules := nsg.SecurityRules
Expect(len(*rules)).NotTo(Equal(0))
var found bool
for _, rule := range *rules {
if strings.Contains(*rule.SourceAddressPrefix, "AzureCloud") {
found = true
}
}
Expect(found).To(BeTrue())
})
})

func validateUnsharedSecurityRuleExists(nsg *aznetwork.SecurityGroup, ip string, port string) bool {
Expand Down