...

Source file src/github.com/google/go-containerregistry/pkg/v1/remote/check_e2e_test.go

Documentation: github.com/google/go-containerregistry/pkg/v1/remote

     1  // Copyright 2019 Google LLC All Rights Reserved.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //    http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  //go:build integration
    16  // +build integration
    17  
    18  package remote
    19  
    20  import (
    21  	"net/http"
    22  	"testing"
    23  
    24  	"github.com/google/go-containerregistry/pkg/authn"
    25  	"github.com/google/go-containerregistry/pkg/name"
    26  )
    27  
    28  func TestCheckPushPermission_Real(t *testing.T) {
    29  	// Tests should not run in an environment where these registries can
    30  	// be pushed to.
    31  	for _, r := range []name.Reference{
    32  		name.MustParseReference("ubuntu"),
    33  		name.MustParseReference("google/cloud-sdk"),
    34  		name.MustParseReference("microsoft/dotnet:sdk"),
    35  		name.MustParseReference("gcr.io/non-existent-project/made-up"),
    36  		name.MustParseReference("gcr.io/google-containers/foo"),
    37  		name.MustParseReference("quay.io/username/reponame"),
    38  	} {
    39  		t.Run(r.String(), func(t *testing.T) {
    40  			t.Parallel()
    41  			if err := CheckPushPermission(r, authn.DefaultKeychain, http.DefaultTransport); err == nil {
    42  				t.Errorf("CheckPushPermission(%s) returned nil", r)
    43  			}
    44  		})
    45  	}
    46  }
    47  

View as plain text