github.com/yoctocloud/packer@v0.6.2-0.20160520224004-e11a0a18423f/builder/azure/arm/authenticate_test.go (about) 1 package arm 2 3 import ( 4 "github.com/Azure/go-autorest/autorest/azure" 5 "testing" 6 ) 7 8 // Behavior is the most important thing to assert for ServicePrincipalToken, but 9 // that cannot be done in a unit test because it involves network access. Instead, 10 // I assert the expected intertness of this class. 11 func TestNewAuthenticate(t *testing.T) { 12 testSubject := NewAuthenticate(azure.PublicCloud, "clientID", "clientString", "tenantID") 13 spn, err := testSubject.getServicePrincipalToken() 14 if err != nil { 15 t.Fatalf(err.Error()) 16 } 17 18 if spn.Token.AccessToken != "" { 19 t.Errorf("spn.Token.AccessToken: expected=\"\", actual=%s", spn.Token.AccessToken) 20 } 21 if spn.Token.RefreshToken != "" { 22 t.Errorf("spn.Token.RefreshToken: expected=\"\", actual=%s", spn.Token.RefreshToken) 23 } 24 if spn.Token.ExpiresIn != "" { 25 t.Errorf("spn.Token.ExpiresIn: expected=\"\", actual=%s", spn.Token.ExpiresIn) 26 } 27 if spn.Token.ExpiresOn != "" { 28 t.Errorf("spn.Token.ExpiresOn: expected=\"\", actual=%s", spn.Token.ExpiresOn) 29 } 30 if spn.Token.NotBefore != "" { 31 t.Errorf("spn.Token.NotBefore: expected=\"\", actual=%s", spn.Token.NotBefore) 32 } 33 if spn.Token.Resource != "" { 34 t.Errorf("spn.Token.Resource: expected=\"\", actual=%s", spn.Token.Resource) 35 } 36 if spn.Token.Type != "" { 37 t.Errorf("spn.Token.Type: expected=\"\", actual=%s", spn.Token.Type) 38 } 39 }