def test_02_exception_raised_on_failed_login(self): ''' Story: User logs in with an invalid API token. Ensure that a HTTPError is raised in response. ''' from caspyr import Session with self.assertRaises(HTTPError): self.session = Session.login(refresh_token='12345')
def get_data(): req = request.get_json() token = req['cspapitoken'] s = Session.login(token) serialData = {} deployments = len(Deployment.list(s)) bps = len(Blueprint.list(s)) projects = len(Project.list(s)) cloudaccounts = len(CloudAccount.list(s)) serialData['deployments'] = deployments serialData['bps'] = bps serialData['projects'] = projects serialData['cloudaccounts'] = cloudaccounts return jsonify(serialData)
def setUp(self, api_token=api_token): from caspyr import Session self.session = Session.login(refresh_token=api_token) self.aws_cloud_account_name = "trading aws" self.aws_region = "us-west-1" self.aws_cloud_zone_name = "dev aws" self.aws_image_name = "ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-20171026.1" self.aws_network_profile_name = "trading aws network profile" self.aws_storage_profile_name = "trading aws storage profile" self.aws_storage_policy_name = "gp2" self.aws_flavor_name = "t2.small" self.aws_storage_device_type = "ebs" self.aws_storage_volume_type = "gp2" self.azure_cloud_account_name = "trading azure" self.azure_region = "westus" self.azure_cloud_zone_name = "dev azure" self.azure_image_name = "Canonical:UbuntuServer:16.04-LTS:latest" self.azure_network_profile_name = "trading azure network profile" self.azure_storage_profile_name = "trading azure storage profile" self.azure_storage_policy_name = "standard lrs" self.azure_storage_storage_type = "managed_disks" self.azure_storage_disk_type = "standard_lrs" self.azure_flavor_name = "Standard_B2s" self.azure_storage_os_disk_caching = "read_only" self.azure_storage_data_caching = "read_only" self.image_mapping_name = "ubuntu" self.flavor_mapping_name = "small" self.network_profile_tags = [{ "key": "env", "value": "dev" }] self.storage_policy_tags = [{ "key": "performance", "value": "standard"}] self.project_name = "trading" details = '../secrets.json' with open(details) as f: data = json.load(f) for i in data: if i['token']==api_token: self.aws_access_key = i["aws_access_key"] self.aws_secret_key = i["aws_secret_key"] self.azure_subscription_id = i["azure_subscription_id"] self.azure_tenant_id = i["azure_tenant_id"] self.azure_application_id = i["azure_application_id"] self.azure_application_key = i["azure_application_key"] f.closed
def setUp(self): from caspyr import Session api_token = os.getenv('api_token') self.session = Session.login(refresh_token=api_token)
def get_ips(token, cluster_name): s = Session.login(token) ips = [Machine.get_ip(s, master['id']) for master in Machine.find_by_tag(s, key=cluster_name, value='master')] print(ips)
def main(): args = getargs() session = Session.login(args.token) setup_org(session)