forked from anoop2811/saml2aws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
input_test.go
38 lines (35 loc) · 1.02 KB
/
input_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
package saml2aws
import (
"testing"
"github.com/guidewire/saml2aws/v2/pkg/creds"
)
func TestLoginDetails_Validate(t *testing.T) {
type fields struct {
Username string
Password string
URL string
}
tests := []struct {
name string
fields fields
wantErr bool
}{
// TODO: Add test cases.
{name: "hostname missing error", fields: fields{}, wantErr: true},
{name: "username missing error", fields: fields{URL: "id.example.com"}, wantErr: true},
{name: "password missing error", fields: fields{URL: "id.example.com", Username: "test"}, wantErr: true},
{name: "ok", fields: fields{URL: "id.example.com", Username: "test", Password: "test"}, wantErr: false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ld := &creds.LoginDetails{
Username: tt.fields.Username,
Password: tt.fields.Password,
URL: tt.fields.URL,
}
if err := ld.Validate(); (err != nil) != tt.wantErr {
t.Errorf("LoginDetails.Validate() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}