forked from hashicorp/go-tfe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_setting_saml_integration_test.go
77 lines (62 loc) · 2.07 KB
/
admin_setting_saml_integration_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
//go:build integration
// +build integration
package tfe
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestAdminSettings_SAML_Read(t *testing.T) {
skipIfCloud(t)
client := testClient(t)
ctx := context.Background()
samlSettings, err := client.Admin.Settings.SAML.Read(ctx)
require.NoError(t, err)
assert.Equal(t, "saml", samlSettings.ID)
assert.NotNil(t, samlSettings.Enabled)
assert.NotNil(t, samlSettings.Debug)
assert.NotNil(t, samlSettings.SLOEndpointURL)
assert.NotNil(t, samlSettings.SSOEndpointURL)
assert.NotNil(t, samlSettings.AttrUsername)
assert.NotNil(t, samlSettings.AttrGroups)
assert.NotNil(t, samlSettings.AttrSiteAdmin)
assert.NotNil(t, samlSettings.SiteAdminRole)
assert.NotNil(t, samlSettings.SSOAPITokenSessionTimeout)
assert.NotNil(t, samlSettings.ACSConsumerURL)
assert.NotNil(t, samlSettings.MetadataURL)
assert.NotNil(t, samlSettings.TeamManagementEnabled)
assert.NotNil(t, samlSettings.Certificate)
assert.NotNil(t, samlSettings.AuthnRequestsSigned)
assert.NotNil(t, samlSettings.WantAssertionsSigned)
assert.NotNil(t, samlSettings.PrivateKey)
}
func TestAdminSettings_SAML_Update(t *testing.T) {
skipIfCloud(t)
client := testClient(t)
ctx := context.Background()
samlSettings, err := client.Admin.Settings.SAML.Read(ctx)
require.NoError(t, err)
enabled := false
debug := false
samlSettings, err = client.Admin.Settings.SAML.Update(ctx, AdminSAMLSettingsUpdateOptions{
Enabled: Bool(enabled),
Debug: Bool(debug),
})
require.NoError(t, err)
assert.Equal(t, enabled, samlSettings.Enabled)
assert.Equal(t, debug, samlSettings.Debug)
}
func TestAdminSettings_SAML_RevokeIdpCert(t *testing.T) {
skipIfCloud(t)
client := testClient(t)
ctx := context.Background()
samlSettings, err := client.Admin.Settings.SAML.Read(ctx)
require.NoError(t, err)
if !samlSettings.Enabled {
t.Skip("SAML is not enabled, skipping Revoke IDP Cert test.")
}
samlSettings, err = client.Admin.Settings.SAML.RevokeIdpCert(ctx)
require.NoError(t, err)
assert.NotNil(t, samlSettings.IDPCert)
}