def testGetProjectIdFromHttpHostCustomDomain(self): os.environ['HTTP_HOST'] = 'www.mydomain.com' project_id = mimic.GetProjectIdFromHttpHost(os.environ) self.assertEquals('www', project_id) os.environ['HTTP_HOST'] = 'proj1.www.mydomain.com' project_id = mimic.GetProjectIdFromHttpHost(os.environ) self.assertEquals('proj1', project_id)
def testGetProjectIdFromHttpHostAppspot(self): os.environ['HTTP_HOST'] = 'project-id.your-app-id.appspot.com' project_id = mimic.GetProjectIdFromHttpHost(os.environ) self.assertEquals('project-id', project_id) # Must have project id subdomain self.CheckHostParseFailure('your-app-id.appspot.com') self.CheckHostParseFailure('some-other-app-id.appspot.com')
def testGetProjectIdFromHttpHostIpv4(self): os.environ['HTTP_HOST'] = '0.0.0.0' project_id = mimic.GetProjectIdFromHttpHost(os.environ) self.assertEquals(None, project_id)
def testGetProjectIdFromHttpHostCustomDomainDashDotDash(self): os.environ['HTTP_HOST'] = 'proj2-dot-www.mydomain.com' project_id = mimic.GetProjectIdFromHttpHost(os.environ) self.assertEquals('proj2', project_id)
def testGetProjectIdFromHttpHostLocalhost(self): os.environ['HTTP_HOST'] = 'localhost:8080' os.environ['SERVER_NAME'] = 'localhost' project_id = mimic.GetProjectIdFromHttpHost(os.environ) self.assertEquals(None, project_id)
def testGetProjectIdFromHttpHostAppspotDashDotDash(self): os.environ['HTTP_HOST'] = 'project-id-dot-your-app-id.appspot.com' project_id = mimic.GetProjectIdFromHttpHost(os.environ) self.assertEquals('project-id', project_id)
def testGetProjectIdFromHttpHostAppspotWithPort(self): os.environ['HTTP_HOST'] = 'project-id.your-app-id.appspot.com:12345' project_id = mimic.GetProjectIdFromHttpHost(os.environ) self.assertEquals('project-id', project_id)
def CheckHostParseFailure(self, http_host): os.environ['HTTP_HOST'] = http_host project_id = mimic.GetProjectIdFromHttpHost(os.environ) self.assertEquals(None, project_id)