Beispiel #1
0
def test_no_credentials(coresys: CoreSys):
    """Test no credentials."""
    docker = DockerInterface(coresys)
    coresys.docker.config.registries = {
        DOCKER_HUB: {
            "username": "******",
            "password": "******"
        }
    }
    assert not docker._get_credentials("ghcr.io/homeassistant")
    assert not docker._get_credentials(
        "ghcr.io/homeassistant/amd64-supervisor")
async def test_docker_image_platform(coresys: CoreSys, cpu_arch: str,
                                     platform: str):
    """Test platform set correctly from arch."""
    with patch.object(coresys.docker.images,
                      "pull",
                      return_value=Mock(id="test:1.2.3")) as pull:
        instance = DockerInterface(coresys)
        await instance.install(AwesomeVersion("1.2.3"), "test", arch=cpu_arch)
        assert pull.call_count == 1
        assert pull.call_args == call("test:1.2.3", platform=platform)
async def test_docker_image_default_platform(coresys: CoreSys):
    """Test platform set using supervisor arch when omitted."""
    with patch.object(type(coresys.supervisor), "arch",
                      PropertyMock(return_value="i386")), patch.object(
                          coresys.docker.images,
                          "pull",
                          return_value=Mock(id="test:1.2.3")) as pull:
        instance = DockerInterface(coresys)
        await instance.install(AwesomeVersion("1.2.3"), "test")
        assert pull.call_count == 1
        assert pull.call_args == call("test:1.2.3", platform="linux/386")
Beispiel #4
0
def test_matching_credentials(coresys: CoreSys):
    """Test no matching credentials."""
    docker = DockerInterface(coresys)
    coresys.docker.config.registries = {
        "ghcr.io": {
            "username": "******",
            "password": "******"
        },
        DOCKER_HUB: {
            "username": "******",
            "password": "******"
        },
    }

    credentials = docker._get_credentials(
        "ghcr.io/homeassistant/amd64-supervisor")
    assert credentials["registry"] == "ghcr.io"

    credentials = docker._get_credentials("homeassistant/amd64-supervisor")
    assert credentials["username"] == "Spongebob Squarepants"
    assert "registry" not in credentials