forked from oracle/terraform-provider-oci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
data_source_obmcs_identity_api_keys_test.go
80 lines (71 loc) · 2.23 KB
/
data_source_obmcs_identity_api_keys_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
package main
import (
"testing"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
"github.com/oracle/bmcs-go-sdk"
"github.com/stretchr/testify/suite"
)
type DatasourceIdentityAPIKeysTestSuite struct {
suite.Suite
Client *baremetal.Client
Config string
Provider terraform.ResourceProvider
Providers map[string]terraform.ResourceProvider
ResourceName string
List *baremetal.ListAPIKeyResponses
}
func (s *DatasourceIdentityAPIKeysTestSuite) SetupTest() {
_, tokenFn := tokenize()
s.Client = testAccClient
s.Provider = testAccProvider
s.Providers = testAccProviders
s.Config = testProviderConfig() + tokenFn(`
resource "oci_identity_user" "t" {
name = "-tf-test"
description = "automated test user"
}
resource "oci_identity_api_key" "t" {
user_id = "${oci_identity_user.t.id}"
key_value = <<EOF
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtBLQAGmKJ7tpfzYJyqLG
ZDwHL51+d6T8Z00BnP9CFfzxZZZ48PcYSUHuTyCM8mR5JqYLyH6C8tZ/DKqwxUnc
ONgBytG3MM42bgxfHIhsZRj5rCz1oqWlSLuXvgww1kuqWnt6r+NtnXog439YsGTH
RotrTLTdEgOxH0EFP5uHUc9w/Uix7rWU7GB2ra060oeTB/hKpts5U70eI2EI6ec9
1sJdUIj7xNfBJeQQrz4CFUrkyzL06211CFvhmxH2hA9gBKOqC3rGL8XraHZBhGWn
mXlrQB7nNKsJrrv5fHwaPDrAY4iNP2W0q3LRpyNigJ6cgRuGJhHa82iHPmxgIx8m
fwIDAQAB
-----END PUBLIC KEY-----
EOF
}`, nil)
s.ResourceName = "data.oci_identity_api_keys.t"
}
func (s *DatasourceIdentityAPIKeysTestSuite) TestAccDatasourceIdentityAPIKeys_basic() {
resource.Test(s.T(), resource.TestCase{
PreventPostDestroyRefresh: true,
Providers: s.Providers,
Steps: []resource.TestStep{
{
ImportState: true,
ImportStateVerify: true,
Config: s.Config,
},
{
Config: s.Config + `
data "oci_identity_api_keys" "t" {
user_id = "${oci_identity_user.t.id}"
}`,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet(s.ResourceName, "api_keys.0.id"),
resource.TestCheckResourceAttr(s.ResourceName, "api_keys.#", "1"),
),
},
},
},
)
}
func TestDatasourceIdentityAPIKeysTestSuite(t *testing.T) {
suite.Run(t, new(DatasourceIdentityAPIKeysTestSuite))
}