├── .gitignore ├── .travis.yml ├── run_all.sh ├── test_config_server.py ├── test_eureka_server.py └── test_zuul_service.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Java class files 2 | *.class 3 | 4 | # Eclipse project files 5 | .classpath 6 | .project 7 | .settings/ 8 | 9 | # Intellij project files 10 | *.iml 11 | *.ipr 12 | *.iws 13 | .idea/ 14 | 15 | .DS_Store/ 16 | /target 17 | 18 | /target 19 | /target/ 20 | **/target/ 21 | 22 | .DS_Store 23 | .cache 24 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | sudo: required 3 | install: pip install httplib2 4 | before_install: 5 | - sudo curl -k -o /usr/local/bin/ecs-cli https://s3.amazonaws.com/amazon-ecs-cli/ecs-cli-linux-amd64-latest 6 | - sudo chmod +x /usr/local/bin/ecs-cli 7 | notifications: 8 | email: 9 | - carnell28@gmail.com 10 | on_success: always 11 | on_failure: always 12 | env: 13 | global: 14 | - secure: JFgKN3gcLcM166+6uMIEUhU0LGZyiFRM6n0o9HTKJR9rKpmNKNH5QR5vf8PW5WGZyhNE9gBt502bPU2Odnf2qieYc0La2SHZodJzwdhu66MHaQ/79iHvZkR0BYQRsQsB15q2ZZgXMFKuxloytO1A4kdQgGLP0M/1+kVeyOlCHQYw8k6u/robuJ/gIQkz9GvwTRkv3ytk7STatya4/XBT0PE5BIBta/KL+nnBAqoWsRe3iAsopWo77qLqXpTK3FmzhGBpRo6LwCYDDCClqHVzWnubNwV0p4AAGs/r7eNjFt1wcNADeRKo+UdXIGz08XtWbt5293AywlR9tDD+FtHfUMeqEq1nwCkbx5Ay//QCwkkFCEuK+bNFGwo0h1QpiBEcN/0sNVTtIxngLo1BDN/vS2uJfz6wkiy5h0dQmuurQtwe14mkNh9yZ5QnktVKAJzbm+L8T0snBSHMZPYYXDRudpjIaeWAT/cDZUJmSKlcom+FN2iat/rQObaOvGjNzXEg59SmEGRqYjUYnTcWsE89CxXwBKYhNi4N9RY5bxqioOo4yAF88AbZRlsHDtmoeZctlXtNSoqSrgHyKRTns4YjaKCP3zddtzyOJvBoOfQvLtE3ZXBTVR2WEaPUFbbQLMAcYaGMJ4UPvWw4y1ogC3TMXW3lYDJQdeG/nnK6YRKNq78= 15 | - secure: MQDB9s99Vee4jLbwWhQb/VlpGOon+b932hw53RCuXvrGxJK4UcSgVb7SibHSOfO989indY65G742OjY9x7ku1Em5UIGV5b8Xta2AjQtBERqYy2wcq2j9jbnsXZWn34Y6mwQD91coyYFd6C1Mk7ypY726+4owed1c/IHxdxIxe67V9x5/RoVhNaMymTIxBxwo6TRWQvORMuIQDo/Gu+DW0UHWpi16b8fFOFskdVrJUXsPbB4+dsuPMjcZwDQ2b4hFl6zuz3iCzLtvyHL3h+GcG0MG+lpHvYqlU1r7nz1S9Q9G4671I1C7VInzleHSubpPx+4cxERiSnXre9nyx6G4X91WdZgh0c91S+yWfclOjWrEF8YduXUhaCj/JaKqaE5ZyVfclhFghqedmspYiFsDBzO86zMryKWvnY8ZuvVsu25tTeGgW5hfl3p7obZGQugHbEBJqW9aw/LRMdD+iZm2dzDWgTUYkXmEc6+Mv3ZdNfJ7+p1AINKiZxhvx9H8sbXNC4b2Q7uyfrJeVO3cae8qP8NbHccsQpusDPvgicdxRBKmQHEObCYpQIKhCrIQ75Q1kDpRMvpv3eLWzDwODUYe/EpwrL2NDTxrRm5rqbN6/nOZAFRSOdBdiudFNBT3U0Es9ppECHmQgm2iyDHt7A5C6ofqhek8XUtbrFp+9Tx8CGk= 16 | script: 17 | - echo "Sleeping 60 seconds to let containers warm up" 18 | - sleep 60 19 | - echo "Beginning platform tests" 20 | - python test_config_server.py 21 | - python test_eureka_server.py 22 | - python test_zuul_service.py 23 | -------------------------------------------------------------------------------- /run_all.sh: -------------------------------------------------------------------------------- 1 | #IP Address of the VM Hosting the container 2 | python test_config_server.py 3 | python test_eureka_server.py 4 | python test_zuul_service.py 5 | -------------------------------------------------------------------------------- /test_config_server.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import logging 3 | import json 4 | import string 5 | import argparse 6 | import os 7 | from httplib2 import Http 8 | 9 | class TestConfigServer(unittest.TestCase): 10 | 11 | def call_config_service(self,serviceName,serviceEnv): 12 | targetUri = "http://{}:8888/{}/{}".format(containerIP,serviceName,serviceEnv) 13 | http_obj = Http(".cache") 14 | (resp, content) = http_obj.request( 15 | uri=targetUri, 16 | method='GET', 17 | headers={'Content-Type': 'application/json; charset=UTF-8', 'connection': 'close'}) 18 | return resp,content 19 | 20 | 21 | def test_licensingservice_aws_dev(self): 22 | http_obj = Http(".cache") 23 | (resp, content) = self.call_config_service("licensingservice","aws-dev") 24 | results = json.loads(content.decode("utf-8")) 25 | self.assertEqual(resp.status, 200) 26 | self.assertEquals("https://github.com/carnellj/config-repo/licensingservice/licensingservice-aws-dev.yml", 27 | results["propertySources"][0]["name"]) 28 | 29 | def test_licensingservice_default(self): 30 | http_obj = Http(".cache") 31 | (resp, content) = self.call_config_service("licensingservice","default") 32 | results = json.loads(content.decode("utf-8")) 33 | self.assertEqual(resp.status, 200) 34 | self.assertEquals("https://github.com/carnellj/config-repo/licensingservice/licensingservice.yml", 35 | results["propertySources"][0]["name"]) 36 | 37 | def test_organizationservice_default(self): 38 | http_obj = Http(".cache") 39 | (resp, content) = self.call_config_service("organizationservice","default") 40 | results = json.loads(content.decode("utf-8")) 41 | self.assertEqual(resp.status, 200) 42 | self.assertEquals("https://github.com/carnellj/config-repo/organizationservice/organizationservice.yml", 43 | results["propertySources"][0]["name"]) 44 | 45 | def test_organizationservice_aws_dev(self): 46 | http_obj = Http(".cache") 47 | (resp, content) = self.call_config_service("organizationservice","aws-dev") 48 | results = json.loads(content.decode("utf-8")) 49 | self.assertEqual(resp.status, 200) 50 | self.assertEquals("https://github.com/carnellj/config-repo/organizationservice/organizationservice-aws-dev.yml", 51 | results["propertySources"][0]["name"]) 52 | 53 | 54 | 55 | 56 | if __name__ == '__main__': 57 | containerIP = os.getenv('CONTAINER_IP',"192.168.99.100") 58 | print "Running config service platform tests against container ip: {}".format(containerIP) 59 | unittest.main() 60 | -------------------------------------------------------------------------------- /test_eureka_server.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import logging 3 | import json 4 | import string 5 | import argparse 6 | import os 7 | from httplib2 import Http 8 | 9 | class TestEurekaServer(unittest.TestCase): 10 | 11 | def call_eureka_service(self,serviceName): 12 | targetUri = "http://{}:8761/eureka/apps/{}".format(containerIP,serviceName) 13 | http_obj = Http(".cache") 14 | (resp, content) = http_obj.request( 15 | uri=targetUri, 16 | method='GET', 17 | headers={'Content-Type': 'application/json; charset=UTF-8', 'connection': 'close', 'Accept': 'application/json'}) 18 | return resp,content 19 | 20 | def service_present(self, results, serviceName): 21 | if results["application"]["name"]==serviceName: 22 | return True 23 | False 24 | 25 | def assert_eureka_service(self,servicename): 26 | http_obj = Http(".cache") 27 | (resp, content) = self.call_eureka_service(servicename) 28 | results = json.loads(content.decode("utf-8")) 29 | self.assertEqual(resp.status, 200) 30 | self.assertEquals(True, self.service_present(results, servicename)) 31 | 32 | def test_licensingservice(self): 33 | self.assert_eureka_service("LICENSINGSERVICE") 34 | 35 | def test_organizationservice(self): 36 | self.assert_eureka_service("ORGANIZATIONSERVICE") 37 | 38 | def test_configservice(self): 39 | self.assert_eureka_service("CONFIGSERVER") 40 | 41 | def test_zuulservice(self): 42 | self.assert_eureka_service("ZUULSERVICE") 43 | 44 | if __name__ == '__main__': 45 | containerIP = os.getenv('CONTAINER_IP',"192.168.99.100") 46 | print "Running eureka service platform tests against container ip: {}".format(containerIP) 47 | unittest.main() 48 | -------------------------------------------------------------------------------- /test_zuul_service.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import logging 3 | import json 4 | import string 5 | import argparse 6 | import os 7 | import urllib 8 | from httplib2 import Http 9 | 10 | class TestZuulService(unittest.TestCase): 11 | 12 | def build_headers(self): 13 | return {'Content-Type': 'application/json; charset=UTF-8', 14 | 'connection': 'close', 15 | 'Accept': 'application/json', 16 | 'Authorization': 'Bearer {}'.format(oauthtoken)} 17 | 18 | def call_zuul_service(self): 19 | targetUri = "http://{}:5555/routes".format(containerIP) 20 | http_obj = Http(".cache") 21 | (resp, content) = http_obj.request( 22 | uri=targetUri, 23 | method='GET', 24 | headers=self.build_headers()) 25 | return resp,content 26 | 27 | def call_org_service(self): 28 | targetUri = "http://{}:5555/api/organization/v1/organizations/e254f8c-c442-4ebe-a82a-e2fc1d1ff78a".format(containerIP) 29 | http_obj = Http(".cache") 30 | (resp, content) = http_obj.request( 31 | uri=targetUri, 32 | method='GET', 33 | headers=self.build_headers()) 34 | return resp,content 35 | 36 | def call_licensing_service(self): 37 | targetUri = "http://{}:5555/api/licensing/v1/organizations/e254f8c-c442-4ebe-a82a-e2fc1d1ff78a/licenses/f3831f8c-c338-4ebe-a82a-e2fc1d1ff78a".format(containerIP) 38 | http_obj = Http(".cache") 39 | (resp, content) = http_obj.request( 40 | uri=targetUri, 41 | method='GET', 42 | headers=self.build_headers()) 43 | return resp,content 44 | 45 | def test_zuul_service_routes(self): 46 | (resp, content) = self.call_zuul_service() 47 | results = json.loads(content.decode("utf-8")) 48 | self.assertEqual(resp.status, 200) 49 | self.assertEquals("organizationservice", results["/api/organization/**"]) 50 | self.assertEquals("licensingservice", results[ "/api/licensing/**"]) 51 | self.assertEquals("authenticationservice", results["/api/auth/**"]) 52 | self.assertEquals(3, len(results)) 53 | 54 | def test_org_service(self): 55 | (resp, content) = self.call_org_service() 56 | results = json.loads(content.decode("utf-8")) 57 | self.assertEqual(resp.status, 200) 58 | self.assertEqual("e254f8c-c442-4ebe-a82a-e2fc1d1ff78a", results["id"]) 59 | self.assertEqual("customer-crm-co", results["name"]) 60 | self.assertEqual("Mark Balster", results["contactName"]) 61 | self.assertEqual("mark.balster@custcrmco.com", results["contactEmail"]) 62 | self.assertEqual("823-555-1212", results["contactPhone"]) 63 | 64 | def test_licensing_service(self): 65 | (resp, content) = self.call_licensing_service() 66 | results = json.loads(content.decode("utf-8")) 67 | self.assertEqual(resp.status, 200) 68 | self.assertEqual("f3831f8c-c338-4ebe-a82a-e2fc1d1ff78a", results["licenseId"]) 69 | self.assertEqual("e254f8c-c442-4ebe-a82a-e2fc1d1ff78a", results["organizationId"]) 70 | self.assertEqual("Mark Balster", results["contactName"]) 71 | self.assertEqual("mark.balster@custcrmco.com", results["contactEmail"]) 72 | self.assertEqual("823-555-1212", results["contactPhone"]) 73 | self.assertEqual("CustomerPro", results["productName"]) 74 | 75 | def retrieve_oauth_service(): 76 | targetUri = "http://{}:5555/api/auth/oauth/token ".format(containerIP) 77 | http = Http(".cache") 78 | body = {'grant_type': 'password', 79 | 'scope': 'webclient', 80 | 'username':'william.woodward', 81 | 'password':'password2'} 82 | 83 | content = http.request( 84 | uri=targetUri, 85 | method="POST", 86 | headers={'Content-type': 'application/x-www-form-urlencoded', 'Authorization': 'Basic ZWFnbGVleWU6dGhpc2lzc2VjcmV0'}, 87 | body=urllib.urlencode(body)) 88 | results = json.loads(content[1]) 89 | return results.get("access_token") 90 | 91 | if __name__ == '__main__': 92 | containerIP = os.getenv('CONTAINER_IP',"192.168.99.100") 93 | print "Running zuul service platform tests against container ip: {}".format(containerIP) 94 | oauthtoken = retrieve_oauth_service() 95 | print "OAuthToken successfully retrieved: {}".format(oauthtoken) 96 | unittest.main() 97 | --------------------------------------------------------------------------------