terraform-provider-google/google/data_source_google_client_openid_userinfo_test.go
The Magician dff7b250c1 Add a datasource for retrieving the client email from OpenID Connect (#3103)
<!-- This change is generated by MagicModules. -->
/cc @rileykarson
2019-02-25 12:39:12 -08:00

47 lines
1.3 KiB
Go

package google
import (
"testing"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccDataSourceGoogleClientOpenIDUserinfo_basic(t *testing.T) {
t.Parallel()
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccCheckGoogleClientOpenIDUserinfo_basic,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("data.google_client_openid_userinfo.me", "email"),
),
},
},
})
}
const testAccCheckGoogleClientOpenIDUserinfo_basic = `
provider "google" {
alias = "google-scoped"
# We need to add an additional scope to test this; because our tests rely on
# every env var being set, we can just add an alias with the appropriate
# scopes. This will fail if someone uses an access token instead of creds
# unless they've configured the userinfo.email scope.
scopes = [
"https://www.googleapis.com/auth/compute",
"https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/ndev.clouddns.readwrite",
"https://www.googleapis.com/auth/devstorage.full_control",
"https://www.googleapis.com/auth/userinfo.email",
]
}
data "google_client_openid_userinfo" "me" {
provider = "google.google-scoped"
}
`