Ejemplo n.º 1
0
def test_get_asset_nonexistent(requests_mock, orca_client: OrcaClient) -> None:
    mock_response = {"error": ""}
    requests_mock.get(f"{ORCA_API_DNS_NAME}/assets/1234567", json=mock_response)
    res = orca_client.get_asset(asset_unique_id="1234567")
    assert res == "Asset Not Found"
Ejemplo n.º 2
0
def test_get_asset_should_succeed(requests_mock, orca_client: OrcaClient) -> None:
    mock_response = {
        "type": "vmimage",
        "asset_category": "Image",
        "asset_subcategory": "VM Image",
        "cloud_provider_id": "111111111111",
        "cloud_provider": "aws",
        "cloud_account_id": "10b11111-1111-1111-91d5-11111de11111",
        "cloud_vendor_id": "111111111111",
        "account_name": "111111111111",
        "asset_unique_id": "vmimage_111111e11111_ami-11111c111111d7911",
        "asset_name": "my_test_image-1231asdasjdn",
        "asset_type": "vmimage",
        "asset_type_string": "VM Image",
        "group_unique_id": "vmimage_111111e11111_ami-11111c111111d7911",
        "group_name": "my_test_image-1231asdasjdn",
        "group_type": "vmimage",
        "group_type_string": "NonGroup",
        "cluster_unique_id": "vmimage_111111e11111_ami-11111c111111d7911",
        "cluster_name": "my_test_image-1231asdasjdn",
        "cluster_type": "vmimage",
        "level": 0,
        "asset_vendor_id": "ami-11111c111111d7911",
        "internet_facing": False,
        "internet_facing_new": False,
        "create_time": "2020-07-28T09:10:01+00:00",
        "container_id": "main",
        "compute": {
            "distribution_name": "Ubuntu",
            "distribution_version": "18.04",
            "disks": [
                {
                    "size": "7.75 GB",
                    "used": "2.06 GB"
                }
            ],
            "total_disks_bytes": 8326123520,
            "roles": [
                {
                    "type": "database",
                    "name": "mysql",
                    "is_public": False,
                    "detected_evidence": [
                        "/var/lib/mysql/mysqldb2",
                        "/var/lib/mysql/mysqldb1"
                    ]
                },
                {
                    "type": "ssh",
                    "name": "ssh",
                    "is_public": False
                },
                {
                    "type": "web",
                    "name": "haproxy",
                    "is_public": False
                },
                {
                    "type": "database",
                    "name": "postgresql",
                    "is_public": False,
                    "detected_evidence": [
                        "/var/lib/postgresql/10/main/base/1",
                        "/var/lib/postgresql/10/main",
                        "/var/lib/postgresql/10/main/base/13017",
                        "/var/lib/postgresql/10/main/base/16384",
                        "/var/lib/postgresql/10/main/base/13018"
                    ]
                }
            ]
        },
        "vmimage": {
            "image_id": "ami-11111c111111d7911",
            "image_owner_id": "111111111111",
            "image_name": "my_test_image-1231asdasjdn",
            "image_description": ""
        },
        "configuration": {},
        "state": {
            "status": "exists",
            "status_time": "2020-11-08T13:04:34+00:00",
            "created_at": "2020-11-08T13:04:34+00:00",
            "last_seen": "2020-12-30T10:44:11+00:00",
            "score": 1,
            "severity": "compromised",
            "safe_since": None,
            "unsafe_since": "2020-11-08T13:04:34+00:00"
        }
    }
    requests_mock.get(f"{ORCA_API_DNS_NAME}/assets/vmimage_111111e11111_ami-11111c111111d7911", json=mock_response)
    res = orca_client.get_asset(asset_unique_id="vmimage_111111e11111_ami-11111c111111d7911")
    assert res == mock_response