summaryrefslogtreecommitdiffstats
path: root/client/go/cmd/api_key_test.go
blob: 1deb628c21ead402f186ea9c7acc268627e93f3e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
// Author: mpolden

package cmd

import (
	"path/filepath"
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestAPIKey(t *testing.T) {
	homeDir := filepath.Join(t.TempDir(), ".vespa")
	keyFile := filepath.Join(homeDir, "t1.api-key.pem")

	out, _ := execute(command{args: []string{"api-key", "-a", "t1.a1.i1"}, homeDir: homeDir}, t, nil)
	assert.Contains(t, out, "Success: API private key written to "+keyFile+"\n")

	out, _ = execute(command{args: []string{"api-key", "-a", "t1.a1.i1"}, homeDir: homeDir}, t, nil)
	assert.Contains(t, out, "Error: File "+keyFile+" already exists\nHint: Use -f to overwrite it\n")
	assert.Contains(t, out, "This is your public key")
}