Unverified Commit 44896b15 authored by Victor Engmark's avatar Victor Engmark
Browse files

aws-azure-login: Link Puppeteer to Chromium

Closes #272544.

The test verifies that the command fails for the *right* reason, rather
than the original issue:

> Error: Could not find expected browser (chrome) locally. Run `npm
> install` to download the correct Chromium revision (982053).
parent 7a2dce12
Loading
Loading
Loading
Loading
+13 −7
Original line number Diff line number Diff line
{ lib
, callPackage
, stdenv
, chromium
, fetchFromGitHub
, fetchYarnDeps
, makeWrapper
@@ -7,20 +9,19 @@
, prefetch-yarn-deps
, yarn
}:

stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
  pname = "aws-azure-login";
  version = "3.6.1";

  src = fetchFromGitHub {
    owner = "aws-azure-login";
    repo = "aws-azure-login";
    rev = "v${version}";
    rev = "v${finalAttrs.version}";
    hash = "sha256-PvPnqaKD98h3dCjEOwF+Uc86xCJzn2b9XNHHn13h/2Y=";
  };

  offlineCache = fetchYarnDeps {
    yarnLock = "${src}/yarn.lock";
    yarnLock = "${finalAttrs.src}/yarn.lock";
    hash = "sha256-SXQPRzF6b1FJl5HkyXNm3kGoNSDXux+0RYXBX93mOts=";
  };

@@ -60,11 +61,16 @@ stdenv.mkDerivation rec {
    cp -r . "$out/lib/node_modules/aws-azure-login"

    makeWrapper "${nodejs}/bin/node" "$out/bin/aws-azure-login" \
      --add-flags "$out/lib/node_modules/aws-azure-login/lib/index.js"
      --add-flags "$out/lib/node_modules/aws-azure-login/lib/index.js" \
      --set PUPPETEER_EXECUTABLE_PATH "${lib.getExe chromium}"

    runHook postInstall
  '';

  passthru.tests.aws-azure-login = callPackage ./tests.nix {
    package = finalAttrs.finalPackage;
  };

  meta = {
    description = "Use Azure AD SSO to log into the AWS via CLI";
    homepage = "https://github.com/aws-azure-login/aws-azure-login";
@@ -73,4 +79,4 @@ stdenv.mkDerivation rec {
    maintainers = with lib.maintainers; [ l0b0 ];
    platforms = lib.platforms.all;
  };
}
})
+24 −0
Original line number Diff line number Diff line
{ lib
, runCommand
, package
}:
  runCommand "${package.pname}-tests"
    {
      HOME = "/tmp/home";
    } ''
    mkdir -p "''${HOME}/.aws"
    cat > "''${HOME}/.aws/config" <<'EOF'
    [profile my-profile]
    azure_tenant_id=3f03e308-ada1-45f7-9cc3-ab777eaba2d3
    azure_app_id_uri=4fbf61f5-7302-42e5-9585-b18ad0e4649d
    azure_default_username=user@example.org
    azure_default_role_arn=
    azure_default_duration_hours=1
    azure_default_remember_me=false
    EOF

    ! ${lib.getExe package} --profile=my-profile 2> stderr
    [[ "$(cat stderr)" == 'Unable to recognize page state! A screenshot has been dumped to aws-azure-login-unrecognized-state.png. If this problem persists, try running with --mode=gui or --mode=debug' ]]

    touch $out
  ''