packer-cn/builder/azure/arm/authenticate_test.go

41 lines
1.3 KiB
Go
Raw Normal View History

package arm
import (
"testing"
2018-01-22 20:21:10 -05:00
"github.com/Azure/go-autorest/autorest/azure"
)
// Behavior is the most important thing to assert for ServicePrincipalToken, but
// that cannot be done in a unit test because it involves network access. Instead,
2018-03-13 04:05:14 -04:00
// I assert the expected inertness of this class.
func TestNewAuthenticate(t *testing.T) {
testSubject := NewAuthenticate(azure.PublicCloud, "clientID", "clientString", "tenantID")
spn, err := testSubject.getServicePrincipalToken()
if err != nil {
t.Fatalf(err.Error())
}
2018-04-11 11:25:33 -04:00
if spn.Token().AccessToken != "" {
t.Errorf("spn.Token().AccessToken: expected=\"\", actual=%s", spn.Token().AccessToken)
}
2018-04-11 11:25:33 -04:00
if spn.Token().RefreshToken != "" {
t.Errorf("spn.Token().RefreshToken: expected=\"\", actual=%s", spn.Token().RefreshToken)
}
2018-04-11 11:25:33 -04:00
if spn.Token().ExpiresIn != "" {
t.Errorf("spn.Token().ExpiresIn: expected=\"\", actual=%s", spn.Token().ExpiresIn)
}
2018-04-11 11:25:33 -04:00
if spn.Token().ExpiresOn != "" {
t.Errorf("spn.Token().ExpiresOn: expected=\"\", actual=%s", spn.Token().ExpiresOn)
}
2018-04-11 11:25:33 -04:00
if spn.Token().NotBefore != "" {
t.Errorf("spn.Token().NotBefore: expected=\"\", actual=%s", spn.Token().NotBefore)
}
2018-04-11 11:25:33 -04:00
if spn.Token().Resource != "" {
t.Errorf("spn.Token().Resource: expected=\"\", actual=%s", spn.Token().Resource)
}
2018-04-11 11:25:33 -04:00
if spn.Token().Type != "" {
t.Errorf("spn.Token().Type: expected=\"\", actual=%s", spn.Token().Type)
}
}