@@ -8,6 +8,47 @@ import (
88 "github.com/stretchr/testify/require"
99)
1010
11+ var (
12+ argInput = Inputs {
13+ Username : "input_username" , Password : "input_password" , AppSpecificPassword : "input_appspecificpassword" ,
14+ APIIssuer : "" , APIKeyPath : "" ,
15+ }
16+
17+ argAppleIDConnection = devportalservice.AppleIDConnection {
18+ AppleID : "connection_appleid" , Password : "connection_password" , AppSpecificPassword : "connection_appspecificpassword" ,
19+ }
20+
21+ argAppleIDConnectionMissingPassword = devportalservice.AppleIDConnection {
22+ AppleID : "connection_appleid" , Password : "connection_password" , AppSpecificPassword : "" ,
23+ }
24+
25+ argAPIKeyConnection = devportalservice.APIKeyConnection {
26+ KeyID : "keyconnection_keyID" , IssuerID : "keyconnection_issuerID" , PrivateKey : "keyconnection_PrivateKey" ,
27+ }
28+ )
29+
30+ var (
31+ expectedAppleIDWithArgInput = AppleID {
32+ Username : argInput .Username ,
33+ Password : argInput .Password ,
34+ AppSpecificPassword : argInput .AppSpecificPassword ,
35+ Session : "" ,
36+ }
37+
38+ expectedAppleIDWithArgConnection = AppleID {
39+ Username : argAppleIDConnection .AppleID ,
40+ Password : argAppleIDConnection .Password ,
41+ AppSpecificPassword : argAppleIDConnection .AppSpecificPassword ,
42+ Session : "" ,
43+ }
44+
45+ expectedAppleIDWithAPIKeyConnection = devportalservice.APIKeyConnection {
46+ KeyID : argAPIKeyConnection .KeyID ,
47+ IssuerID : argAPIKeyConnection .IssuerID ,
48+ PrivateKey : argAPIKeyConnection .PrivateKey ,
49+ }
50+ )
51+
1152func TestSelect (t * testing.T ) {
1253 type args struct {
1354 devportalConnection * devportalservice.AppleDeveloperConnection
@@ -48,58 +89,114 @@ func TestSelect(t *testing.T) {
4889 args : args {
4990 devportalConnection : & devportalservice.AppleDeveloperConnection {},
5091 authSources : []Source {& ConnectionAPIKeySource {}, & ConnectionAppleIDSource {}, & InputAPIKeySource {}, & InputAppleIDSource {}},
51- inputs : Inputs {
52- Username : "a" , Password : "b" , AppSpecificPassword : "c" ,
53- APIIssuer : "" , APIKeyPath : "" ,
92+ inputs : argInput ,
93+ },
94+ want : Credentials {
95+ AppleID : & expectedAppleIDWithArgInput ,
96+ APIKey : nil ,
97+ },
98+ },
99+ {
100+ name : "Connection active (Apple ID), inputs (Apple ID) with ConnectionAppleIDSource" ,
101+ args : args {
102+ devportalConnection : & devportalservice.AppleDeveloperConnection {
103+ AppleIDConnection : & argAppleIDConnection ,
104+ },
105+ authSources : []Source {& ConnectionAppleIDSource {}},
106+ inputs : argInput ,
107+ },
108+ want : Credentials {
109+ AppleID : & expectedAppleIDWithArgConnection ,
110+ APIKey : nil ,
111+ },
112+ },
113+ {
114+ name : "Connection active (Apple ID), inputs (Apple ID) with InputAppleIDSource" ,
115+ args : args {
116+ devportalConnection : & devportalservice.AppleDeveloperConnection {
117+ AppleIDConnection : & argAppleIDConnection ,
54118 },
119+ authSources : []Source {& InputAppleIDSource {}},
120+ inputs : argInput ,
121+ },
122+ want : Credentials {
123+ AppleID : & expectedAppleIDWithArgInput ,
124+ APIKey : nil ,
125+ },
126+ },
127+ {
128+ name : "Connection active (Apple ID), inputs (Apple ID) with ConnectionAppleIDFastlaneSource" ,
129+ args : args {
130+ devportalConnection : & devportalservice.AppleDeveloperConnection {
131+ AppleIDConnection : & argAppleIDConnection ,
132+ },
133+ authSources : []Source {& ConnectionAppleIDFastlaneSource {}},
134+ inputs : argInput ,
135+ },
136+ want : Credentials {
137+ AppleID : & expectedAppleIDWithArgConnection ,
138+ APIKey : nil ,
139+ },
140+ },
141+ {
142+ name : "Connection active but missing password (Apple ID), inputs (Apple ID) with ConnectionAppleIDFastlaneSource" ,
143+ args : args {
144+ devportalConnection : & devportalservice.AppleDeveloperConnection {
145+ AppleIDConnection : & argAppleIDConnectionMissingPassword ,
146+ },
147+ authSources : []Source {& ConnectionAppleIDFastlaneSource {}},
148+ inputs : argInput ,
55149 },
56150 want : Credentials {
57151 AppleID : & AppleID {
58- Username : "a" , Password : "b" , AppSpecificPassword : "c" , Session : "" ,
152+ Username : argAppleIDConnection .AppleID ,
153+ Password : argAppleIDConnection .Password ,
154+ AppSpecificPassword : argInput .AppSpecificPassword ,
155+ Session : "" ,
59156 },
60157 APIKey : nil ,
61158 },
62159 },
160+ {
161+ name : "Connection active (Apple ID), inputs (Apple ID) with InputAppleIDFastlaneSource" ,
162+ args : args {
163+ devportalConnection : & devportalservice.AppleDeveloperConnection {
164+ AppleIDConnection : & argAppleIDConnection ,
165+ },
166+ authSources : []Source {& InputAppleIDFastlaneSource {}},
167+ inputs : argInput ,
168+ },
169+ want : Credentials {
170+ AppleID : & expectedAppleIDWithArgInput ,
171+ APIKey : nil ,
172+ },
173+ },
63174 {
64175 name : "Connection active (API Key), inputs (Apple ID)" ,
65176 args : args {
66177 devportalConnection : & devportalservice.AppleDeveloperConnection {
67- APIKeyConnection : & devportalservice.APIKeyConnection {
68- KeyID : "x" , IssuerID : "y" , PrivateKey : "z" ,
69- },
178+ APIKeyConnection : & argAPIKeyConnection ,
70179 },
71180 authSources : []Source {& ConnectionAPIKeySource {}, & ConnectionAppleIDSource {}, & InputAPIKeySource {}, & InputAppleIDSource {}},
72- inputs : Inputs {
73- Username : "a" , Password : "b" , AppSpecificPassword : "c" ,
74- APIIssuer : "" , APIKeyPath : "" ,
75- },
181+ inputs : argInput ,
76182 },
77183 want : Credentials {
78184 AppleID : nil ,
79- APIKey : & devportalservice.APIKeyConnection {
80- KeyID : "x" , IssuerID : "y" , PrivateKey : "z" ,
81- },
185+ APIKey : & expectedAppleIDWithAPIKeyConnection ,
82186 },
83187 },
84188 {
85189 name : "Connection active (API Key), inputs (Apple ID), connection not enabled" ,
86190 args : args {
87191 devportalConnection : & devportalservice.AppleDeveloperConnection {
88- APIKeyConnection : & devportalservice.APIKeyConnection {
89- KeyID : "x" , IssuerID : "y" , PrivateKey : "z" ,
90- },
192+ APIKeyConnection : & argAPIKeyConnection ,
91193 },
92194 authSources : []Source {& InputAPIKeySource {}, & InputAppleIDSource {}},
93- inputs : Inputs {
94- Username : "a" , Password : "b" , AppSpecificPassword : "c" ,
95- APIIssuer : "" , APIKeyPath : "" ,
96- },
195+ inputs : argInput ,
97196 },
98197 want : Credentials {
99- AppleID : & AppleID {
100- Username : "a" , Password : "b" , AppSpecificPassword : "c" , Session : "" ,
101- },
102- APIKey : nil ,
198+ AppleID : & expectedAppleIDWithArgInput ,
199+ APIKey : nil ,
103200 },
104201 },
105202 }
0 commit comments