Text file src/cmd/go/testdata/script/goauth_netrc.txt

     1  # This test exercises the GOAUTH mechanism for specifying
     2  # credentials passed in HTTPS requests to VCS servers.
     3  # See golang.org/issue/26232
     4  
     5  [short] skip
     6  
     7  env GOPROXY=direct
     8  env GOSUMDB=off
     9  
    10  # GOAUTH should default to netrc behavior.
    11  # Without credentials, downloading a module from a path that requires HTTPS
    12  # basic auth should fail.
    13  # Override default location of $HOME/.netrc
    14  env NETRC=$WORK/empty
    15  ! go get vcs-test.golang.org/auth/or401
    16  stderr '^\tserver response: ACCESS DENIED, buddy$'
    17  
    18  # With credentials from a netrc file, it should succeed.
    19  env NETRC=$WORK/netrc
    20  go get vcs-test.golang.org/auth/or401
    21  
    22  # GOAUTH=off should result in failures.
    23  env GOAUTH='off'
    24  # Without credentials, downloading a module from a path that requires HTTPS
    25  # basic auth should fail.
    26  env NETRC=$WORK/empty
    27  ! go get vcs-test.golang.org/auth/or401
    28  stderr '^\tserver response: ACCESS DENIED, buddy$'
    29  
    30  # GOAUTH='off' should ignore credentials from a valid netrc file.
    31  env GOAUTH='off'
    32  env NETRC=$WORK/netrc
    33  ! go get vcs-test.golang.org/auth/or401
    34  stderr '^\tserver response: ACCESS DENIED, buddy$'
    35  
    36  # GOAUTH=off cannot be combined with other authentication commands
    37  env GOAUTH='off; netrc'
    38  env NETRC=$WORK/netrc
    39  ! go get vcs-test.golang.org/auth/or401
    40  stderr 'GOAUTH=off cannot be combined with other authentication commands \(GOAUTH=off; netrc\)'
    41  
    42  # An unset GOAUTH should default to netrc.
    43  env GOAUTH=
    44  # Without credentials, downloading a module from a path that requires HTTPS
    45  # basic auth should fail.
    46  env NETRC=$WORK/empty
    47  ! go get vcs-test.golang.org/auth/or401
    48  stderr '^\tserver response: ACCESS DENIED, buddy$'
    49  
    50  # With credentials from a netrc file, it should succeed.
    51  env NETRC=$WORK/netrc
    52  go get vcs-test.golang.org/auth/or401
    53  
    54  # A missing file should be fail as well.
    55  env NETRC=$WORK/missing
    56  ! go get vcs-test.golang.org/auth/or401
    57  stderr '^\tserver response: ACCESS DENIED, buddy$'
    58  
    59  -- go.mod --
    60  module private.example.com
    61  -- $WORK/empty --
    62  -- $WORK/netrc --
    63  machine vcs-test.golang.org
    64  	login aladdin
    65  	password opensesame
    66  

View as plain text