@@ -43,9 +43,7 @@ describe('auth tests', () => {
43
43
await io . rmRF ( altHome ) ; // ensure it doesn't already exist
44
44
45
45
await auth . createAuthenticationSettings (
46
- id ,
47
- username ,
48
- password ,
46
+ [ { id, username, password} ] ,
49
47
altHome ,
50
48
true
51
49
) ;
@@ -56,7 +54,7 @@ describe('auth tests', () => {
56
54
expect ( fs . existsSync ( altHome ) ) . toBe ( true ) ;
57
55
expect ( fs . existsSync ( altSettingsFile ) ) . toBe ( true ) ;
58
56
expect ( fs . readFileSync ( altSettingsFile , 'utf-8' ) ) . toEqual (
59
- auth . generate ( id , username , password )
57
+ auth . generate ( [ { id, username, password} ] )
60
58
) ;
61
59
62
60
await io . rmRF ( altHome ) ;
@@ -68,17 +66,15 @@ describe('auth tests', () => {
68
66
const password = 'TOKEN' ;
69
67
70
68
await auth . createAuthenticationSettings (
71
- id ,
72
- username ,
73
- password ,
69
+ [ { id, username, password} ] ,
74
70
m2Dir ,
75
71
true
76
72
) ;
77
73
78
74
expect ( fs . existsSync ( m2Dir ) ) . toBe ( true ) ;
79
75
expect ( fs . existsSync ( settingsFile ) ) . toBe ( true ) ;
80
76
expect ( fs . readFileSync ( settingsFile , 'utf-8' ) ) . toEqual (
81
- auth . generate ( id , username , password )
77
+ auth . generate ( [ { id, username, password} ] )
82
78
) ;
83
79
} , 100000 ) ;
84
80
@@ -89,18 +85,15 @@ describe('auth tests', () => {
89
85
const gpgPassphrase = 'GPG' ;
90
86
91
87
await auth . createAuthenticationSettings (
92
- id ,
93
- username ,
94
- password ,
88
+ [ { id, username, password, gpgPassphrase} ] ,
95
89
m2Dir ,
96
- true ,
97
- gpgPassphrase
90
+ true
98
91
) ;
99
92
100
93
expect ( fs . existsSync ( m2Dir ) ) . toBe ( true ) ;
101
94
expect ( fs . existsSync ( settingsFile ) ) . toBe ( true ) ;
102
95
expect ( fs . readFileSync ( settingsFile , 'utf-8' ) ) . toEqual (
103
- auth . generate ( id , username , password , gpgPassphrase )
96
+ auth . generate ( [ { id, username, password, gpgPassphrase} ] )
104
97
) ;
105
98
} , 100000 ) ;
106
99
@@ -115,17 +108,15 @@ describe('auth tests', () => {
115
108
expect ( fs . existsSync ( settingsFile ) ) . toBe ( true ) ;
116
109
117
110
await auth . createAuthenticationSettings (
118
- id ,
119
- username ,
120
- password ,
111
+ [ { id, username, password} ] ,
121
112
m2Dir ,
122
113
true
123
114
) ;
124
115
125
116
expect ( fs . existsSync ( m2Dir ) ) . toBe ( true ) ;
126
117
expect ( fs . existsSync ( settingsFile ) ) . toBe ( true ) ;
127
118
expect ( fs . readFileSync ( settingsFile , 'utf-8' ) ) . toEqual (
128
- auth . generate ( id , username , password )
119
+ auth . generate ( [ { id, username, password} ] )
129
120
) ;
130
121
} , 100000 ) ;
131
122
@@ -140,9 +131,7 @@ describe('auth tests', () => {
140
131
expect ( fs . existsSync ( settingsFile ) ) . toBe ( true ) ;
141
132
142
133
await auth . createAuthenticationSettings (
143
- id ,
144
- username ,
145
- password ,
134
+ [ { id, username, password} ] ,
146
135
m2Dir ,
147
136
false
148
137
) ;
@@ -169,7 +158,7 @@ describe('auth tests', () => {
169
158
</servers>
170
159
</settings>` ;
171
160
172
- expect ( auth . generate ( id , username , password ) ) . toEqual ( expectedSettings ) ;
161
+ expect ( auth . generate ( [ { id, username, password} ] ) ) . toEqual ( expectedSettings ) ;
173
162
} ) ;
174
163
175
164
it ( 'generates valid settings.xml with additional configuration' , ( ) => {
@@ -194,8 +183,50 @@ describe('auth tests', () => {
194
183
</servers>
195
184
</settings>` ;
196
185
197
- expect ( auth . generate ( id , username , password , gpgPassphrase ) ) . toEqual (
198
- expectedSettings
199
- ) ;
186
+ expect (
187
+ auth . generate ( [
188
+ { id, username, password} ,
189
+ { id : 'gpg.passphrase' , gpgPassphrase : gpgPassphrase }
190
+ ] )
191
+ ) . toEqual ( expectedSettings ) ;
192
+ } ) ;
193
+
194
+ it ( 'generates valid settings.xml for multiple repositories' , ( ) => {
195
+ const id0 = 'packages0' ;
196
+ const username0 = 'USER0' ;
197
+ const password0 = '&<>"\'\'"><&0' ;
198
+ const id1 = 'packages1' ;
199
+ const username1 = 'USER1' ;
200
+ const password1 = '&<>"\'\'"><&1' ;
201
+ const gpgPassphrase = 'PASSPHRASE' ;
202
+
203
+ const expectedSettings = `<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
204
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
205
+ xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
206
+ <servers>
207
+ <server>
208
+ <id>${ id0 } </id>
209
+ <username>\${env.${ username0 } }</username>
210
+ <password>\${env.&<>"''"><&0}</password>
211
+ </server>
212
+ <server>
213
+ <id>${ id1 } </id>
214
+ <username>\${env.${ username1 } }</username>
215
+ <password>\${env.&<>"''"><&1}</password>
216
+ </server>
217
+ <server>
218
+ <id>gpg.passphrase</id>
219
+ <passphrase>\${env.${ gpgPassphrase } }</passphrase>
220
+ </server>
221
+ </servers>
222
+ </settings>` ;
223
+
224
+ expect (
225
+ auth . generate ( [
226
+ { id : id0 , username : username0 , password : password0 } ,
227
+ { id : id1 , username : username1 , password : password1 } ,
228
+ { id : 'gpg.passphrase' , gpgPassphrase : gpgPassphrase }
229
+ ] )
230
+ ) . toEqual ( expectedSettings ) ;
200
231
} ) ;
201
232
} ) ;
0 commit comments