1// Copyright 2019 Google LLC
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//     https://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
15package kms_test
16
17import (
18	"context"
19	"fmt"
20	"log"
21	"testing"
22
23	"cloud.google.com/go/internal/testutil"
24	kms "cloud.google.com/go/kms/apiv1"
25	"google.golang.org/api/iterator"
26	kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
27)
28
29func TestIntegration(t *testing.T) {
30	if testing.Short() {
31		t.Skip("skipping integration test in short mode")
32	}
33
34	ctx := context.Background()
35	projectID := testutil.ProjID()
36	c, err := kms.NewKeyManagementClient(ctx)
37	if err != nil {
38		panic(err)
39	}
40
41	it := c.ListKeyRings(ctx, &kmspb.ListKeyRingsRequest{
42		Parent: fmt.Sprintf("projects/%s/locations/global", projectID),
43	})
44
45	for {
46		_, err := it.Next()
47		if err == iterator.Done {
48			break
49		}
50		if err != nil {
51			log.Fatal(err)
52		}
53	}
54}
55