@@ -990,7 +990,6 @@ void assertInstallPluginFromUrl(
990
990
final String pluginId ,
991
991
final String name ,
992
992
final String url ,
993
- final String stagingHash ,
994
993
final boolean isSnapshot ,
995
994
final String shaExtension ,
996
995
final Function <byte [], String > shaCalculator ,
@@ -1065,11 +1064,6 @@ boolean urlExists(Terminal terminal, String urlString) throws IOException {
1065
1064
return urlString .equals (url );
1066
1065
}
1067
1066
1068
- @ Override
1069
- String getStagingHash () {
1070
- return stagingHash ;
1071
- }
1072
-
1073
1067
@ Override
1074
1068
boolean isSnapshot () {
1075
1069
return isSnapshot ;
@@ -1084,19 +1078,13 @@ void jarHellCheck(PluginInfo candidateInfo, Path candidate, Path pluginsDir, Pat
1084
1078
assertPlugin (name , pluginDir , env .v2 ());
1085
1079
}
1086
1080
1087
- public void assertInstallPluginFromUrl (
1088
- final String pluginId ,
1089
- final String name ,
1090
- final String url ,
1091
- final String stagingHash ,
1092
- boolean isSnapshot
1093
- ) throws Exception {
1081
+ public void assertInstallPluginFromUrl (final String pluginId , final String name , final String url , boolean isSnapshot )
1082
+ throws Exception {
1094
1083
final MessageDigest digest = MessageDigest .getInstance ("SHA-512" );
1095
1084
assertInstallPluginFromUrl (
1096
1085
pluginId ,
1097
1086
name ,
1098
1087
url ,
1099
- stagingHash ,
1100
1088
isSnapshot ,
1101
1089
".sha512" ,
1102
1090
checksumAndFilename (digest , url ),
@@ -1111,42 +1099,17 @@ public void testOfficialPlugin() throws Exception {
1111
1099
+ "/analysis-icu-"
1112
1100
+ Build .CURRENT .getQualifiedVersion ()
1113
1101
+ ".zip" ;
1114
- assertInstallPluginFromUrl ("analysis-icu" , "analysis-icu" , url , null , false );
1102
+ assertInstallPluginFromUrl ("analysis-icu" , "analysis-icu" , url , false );
1115
1103
}
1116
1104
1117
1105
public void testOfficialPluginSnapshot () throws Exception {
1118
1106
String url = String .format (
1119
1107
Locale .ROOT ,
1120
- "https://artifacts.opensearch.org/snapshots/plugins/analysis-icu/%s-abc123/analysis-icu-%s.zip" ,
1121
- Version .CURRENT ,
1122
- Build .CURRENT .getQualifiedVersion ()
1123
- );
1124
- assertInstallPluginFromUrl ("analysis-icu" , "analysis-icu" , url , "abc123" , true );
1125
- }
1126
-
1127
- public void testInstallReleaseBuildOfPluginOnSnapshotBuild () {
1128
- String url = String .format (
1129
- Locale .ROOT ,
1130
- "https://artifacts.opensearch.org/snapshots/plugins/analysis-icu/%s-abc123/analysis-icu-%s.zip" ,
1108
+ "https://artifacts.opensearch.org/snapshots/plugins/analysis-icu/%s-SNAPSHOT/analysis-icu-%s.zip" ,
1131
1109
Version .CURRENT ,
1132
1110
Build .CURRENT .getQualifiedVersion ()
1133
1111
);
1134
- // attemping to install a release build of a plugin (no staging ID) on a snapshot build should throw a user exception
1135
- final UserException e = expectThrows (
1136
- UserException .class ,
1137
- () -> assertInstallPluginFromUrl ("analysis-icu" , "analysis-icu" , url , null , true )
1138
- );
1139
- assertThat (e .exitCode , equalTo (ExitCodes .CONFIG ));
1140
- assertThat (e , hasToString (containsString ("attempted to install release build of official plugin on snapshot build of OpenSearch" )));
1141
- }
1142
-
1143
- public void testOfficialPluginStaging () throws Exception {
1144
- String url = "https://artifacts.opensearch.org/snapshots/plugins/analysis-icu/"
1145
- + Version .CURRENT
1146
- + "-abc123/analysis-icu-"
1147
- + Build .CURRENT .getQualifiedVersion ()
1148
- + ".zip" ;
1149
- assertInstallPluginFromUrl ("analysis-icu" , "analysis-icu" , url , "abc123" , false );
1112
+ assertInstallPluginFromUrl ("analysis-icu" , "analysis-icu" , url , true );
1150
1113
}
1151
1114
1152
1115
public void testOfficialPlatformPlugin () throws Exception {
@@ -1157,62 +1120,30 @@ public void testOfficialPlatformPlugin() throws Exception {
1157
1120
+ "-"
1158
1121
+ Build .CURRENT .getQualifiedVersion ()
1159
1122
+ ".zip" ;
1160
- assertInstallPluginFromUrl ("analysis-icu" , "analysis-icu" , url , null , false );
1161
- }
1162
-
1163
- public void testOfficialPlatformPluginSnapshot () throws Exception {
1164
- String url = String .format (
1165
- Locale .ROOT ,
1166
- "https://artifacts.opensearch.org/snapshots/plugins/analysis-icu/%s-abc123/analysis-icu-%s-%s.zip" ,
1167
- Version .CURRENT ,
1168
- Platforms .PLATFORM_NAME ,
1169
- Build .CURRENT .getQualifiedVersion ()
1170
- );
1171
- assertInstallPluginFromUrl ("analysis-icu" , "analysis-icu" , url , "abc123" , true );
1172
- }
1173
-
1174
- public void testOfficialPlatformPluginStaging () throws Exception {
1175
- String url = "https://artifacts.opensearch.org/snapshots/plugins/analysis-icu/"
1176
- + Version .CURRENT
1177
- + "-abc123/analysis-icu-"
1178
- + Platforms .PLATFORM_NAME
1179
- + "-"
1180
- + Build .CURRENT .getQualifiedVersion ()
1181
- + ".zip" ;
1182
- assertInstallPluginFromUrl ("analysis-icu" , "analysis-icu" , url , "abc123" , false );
1123
+ assertInstallPluginFromUrl ("analysis-icu" , "analysis-icu" , url , false );
1183
1124
}
1184
1125
1185
1126
public void testMavenPlugin () throws Exception {
1186
1127
String url = "https://repo1.maven.org/maven2/mygroup/myplugin/1.0.0/myplugin-1.0.0.zip" ;
1187
- assertInstallPluginFromUrl ("mygroup:myplugin:1.0.0" , "myplugin" , url , null , false );
1128
+ assertInstallPluginFromUrl ("mygroup:myplugin:1.0.0" , "myplugin" , url , false );
1188
1129
}
1189
1130
1190
1131
public void testMavenPlatformPlugin () throws Exception {
1191
1132
String url = "https://repo1.maven.org/maven2/mygroup/myplugin/1.0.0/myplugin-" + Platforms .PLATFORM_NAME + "-1.0.0.zip" ;
1192
- assertInstallPluginFromUrl ("mygroup:myplugin:1.0.0" , "myplugin" , url , null , false );
1133
+ assertInstallPluginFromUrl ("mygroup:myplugin:1.0.0" , "myplugin" , url , false );
1193
1134
}
1194
1135
1195
1136
public void testMavenSha1Backcompat () throws Exception {
1196
1137
String url = "https://repo1.maven.org/maven2/mygroup/myplugin/1.0.0/myplugin-1.0.0.zip" ;
1197
1138
MessageDigest digest = MessageDigest .getInstance ("SHA-1" );
1198
- assertInstallPluginFromUrl ("mygroup:myplugin:1.0.0" , "myplugin" , url , null , false , ".sha1" , checksum (digest ), null , (b , p ) -> null );
1139
+ assertInstallPluginFromUrl ("mygroup:myplugin:1.0.0" , "myplugin" , url , false , ".sha1" , checksum (digest ), null , (b , p ) -> null );
1199
1140
assertTrue (terminal .getOutput (), terminal .getOutput ().contains ("sha512 not found, falling back to sha1" ));
1200
1141
}
1201
1142
1202
1143
public void testMavenChecksumWithoutFilename () throws Exception {
1203
1144
String url = "https://repo1.maven.org/maven2/mygroup/myplugin/1.0.0/myplugin-1.0.0.zip" ;
1204
1145
MessageDigest digest = MessageDigest .getInstance ("SHA-512" );
1205
- assertInstallPluginFromUrl (
1206
- "mygroup:myplugin:1.0.0" ,
1207
- "myplugin" ,
1208
- url ,
1209
- null ,
1210
- false ,
1211
- ".sha512" ,
1212
- checksum (digest ),
1213
- null ,
1214
- (b , p ) -> null
1215
- );
1146
+ assertInstallPluginFromUrl ("mygroup:myplugin:1.0.0" , "myplugin" , url , false , ".sha512" , checksum (digest ), null , (b , p ) -> null );
1216
1147
}
1217
1148
1218
1149
public void testOfficialChecksumWithoutFilename () throws Exception {
@@ -1224,17 +1155,7 @@ public void testOfficialChecksumWithoutFilename() throws Exception {
1224
1155
MessageDigest digest = MessageDigest .getInstance ("SHA-512" );
1225
1156
UserException e = expectThrows (
1226
1157
UserException .class ,
1227
- () -> assertInstallPluginFromUrl (
1228
- "analysis-icu" ,
1229
- "analysis-icu" ,
1230
- url ,
1231
- null ,
1232
- false ,
1233
- ".sha512" ,
1234
- checksum (digest ),
1235
- null ,
1236
- (b , p ) -> null
1237
- )
1158
+ () -> assertInstallPluginFromUrl ("analysis-icu" , "analysis-icu" , url , false , ".sha512" , checksum (digest ), null , (b , p ) -> null )
1238
1159
);
1239
1160
assertEquals (ExitCodes .IO_ERROR , e .exitCode );
1240
1161
assertThat (e .getMessage (), startsWith ("Invalid checksum file" ));
@@ -1249,17 +1170,7 @@ public void testOfficialShaMissing() throws Exception {
1249
1170
MessageDigest digest = MessageDigest .getInstance ("SHA-1" );
1250
1171
UserException e = expectThrows (
1251
1172
UserException .class ,
1252
- () -> assertInstallPluginFromUrl (
1253
- "analysis-icu" ,
1254
- "analysis-icu" ,
1255
- url ,
1256
- null ,
1257
- false ,
1258
- ".sha1" ,
1259
- checksum (digest ),
1260
- null ,
1261
- (b , p ) -> null
1262
- )
1173
+ () -> assertInstallPluginFromUrl ("analysis-icu" , "analysis-icu" , url , false , ".sha1" , checksum (digest ), null , (b , p ) -> null )
1263
1174
);
1264
1175
assertEquals (ExitCodes .IO_ERROR , e .exitCode );
1265
1176
assertEquals ("Plugin checksum missing: " + url + ".sha512" , e .getMessage ());
@@ -1269,17 +1180,7 @@ public void testMavenShaMissing() throws Exception {
1269
1180
String url = "https://repo1.maven.org/maven2/mygroup/myplugin/1.0.0/myplugin-1.0.0.zip" ;
1270
1181
UserException e = expectThrows (
1271
1182
UserException .class ,
1272
- () -> assertInstallPluginFromUrl (
1273
- "mygroup:myplugin:1.0.0" ,
1274
- "myplugin" ,
1275
- url ,
1276
- null ,
1277
- false ,
1278
- ".dne" ,
1279
- bytes -> null ,
1280
- null ,
1281
- (b , p ) -> null
1282
- )
1183
+ () -> assertInstallPluginFromUrl ("mygroup:myplugin:1.0.0" , "myplugin" , url , false , ".dne" , bytes -> null , null , (b , p ) -> null )
1283
1184
);
1284
1185
assertEquals (ExitCodes .IO_ERROR , e .exitCode );
1285
1186
assertEquals ("Plugin checksum missing: " + url + ".sha1" , e .getMessage ());
@@ -1294,17 +1195,7 @@ public void testInvalidShaFileMissingFilename() throws Exception {
1294
1195
MessageDigest digest = MessageDigest .getInstance ("SHA-512" );
1295
1196
UserException e = expectThrows (
1296
1197
UserException .class ,
1297
- () -> assertInstallPluginFromUrl (
1298
- "analysis-icu" ,
1299
- "analysis-icu" ,
1300
- url ,
1301
- null ,
1302
- false ,
1303
- ".sha512" ,
1304
- checksum (digest ),
1305
- null ,
1306
- (b , p ) -> null
1307
- )
1198
+ () -> assertInstallPluginFromUrl ("analysis-icu" , "analysis-icu" , url , false , ".sha512" , checksum (digest ), null , (b , p ) -> null )
1308
1199
);
1309
1200
assertEquals (ExitCodes .IO_ERROR , e .exitCode );
1310
1201
assertTrue (e .getMessage (), e .getMessage ().startsWith ("Invalid checksum file" ));
@@ -1323,7 +1214,6 @@ public void testInvalidShaFileMismatchFilename() throws Exception {
1323
1214
"analysis-icu" ,
1324
1215
"analysis-icu" ,
1325
1216
url ,
1326
- null ,
1327
1217
false ,
1328
1218
".sha512" ,
1329
1219
checksumAndString (digest , " repository-s3-" + Build .CURRENT .getQualifiedVersion () + ".zip" ),
@@ -1348,7 +1238,6 @@ public void testInvalidShaFileContainingExtraLine() throws Exception {
1348
1238
"analysis-icu" ,
1349
1239
"analysis-icu" ,
1350
1240
url ,
1351
- null ,
1352
1241
false ,
1353
1242
".sha512" ,
1354
1243
checksumAndString (digest , " analysis-icu-" + Build .CURRENT .getQualifiedVersion () + ".zip\n foobar" ),
@@ -1372,7 +1261,6 @@ public void testSha512Mismatch() throws Exception {
1372
1261
"analysis-icu" ,
1373
1262
"analysis-icu" ,
1374
1263
url ,
1375
- null ,
1376
1264
false ,
1377
1265
".sha512" ,
1378
1266
bytes -> "foobar analysis-icu-" + Build .CURRENT .getQualifiedVersion () + ".zip" ,
@@ -1392,7 +1280,6 @@ public void testSha1Mismatch() throws Exception {
1392
1280
"mygroup:myplugin:1.0.0" ,
1393
1281
"myplugin" ,
1394
1282
url ,
1395
- null ,
1396
1283
false ,
1397
1284
".sha1" ,
1398
1285
bytes -> "foobar" ,
@@ -1426,17 +1313,7 @@ public void testPublicKeyIdMismatchToExpectedPublicKeyId() throws Exception {
1426
1313
final String expectedID = Long .toHexString (verifyingKey .getKeyID ()).toUpperCase (Locale .ROOT );
1427
1314
final IllegalStateException e = expectThrows (
1428
1315
IllegalStateException .class ,
1429
- () -> assertInstallPluginFromUrl (
1430
- icu ,
1431
- icu ,
1432
- url ,
1433
- null ,
1434
- false ,
1435
- ".sha512" ,
1436
- checksumAndFilename (digest , url ),
1437
- verifyingKey ,
1438
- signature
1439
- )
1316
+ () -> assertInstallPluginFromUrl (icu , icu , url , false , ".sha512" , checksumAndFilename (digest , url ), verifyingKey , signature )
1440
1317
);
1441
1318
assertThat (e , hasToString (containsString ("key id [" + actualID + "] does not match expected key id [" + expectedID + "]" )));
1442
1319
}
@@ -1463,17 +1340,7 @@ public void testFailedSignatureVerification() throws Exception {
1463
1340
};
1464
1341
final IllegalStateException e = expectThrows (
1465
1342
IllegalStateException .class ,
1466
- () -> assertInstallPluginFromUrl (
1467
- icu ,
1468
- icu ,
1469
- url ,
1470
- null ,
1471
- false ,
1472
- ".sha512" ,
1473
- checksumAndFilename (digest , url ),
1474
- newSecretKey (),
1475
- signature
1476
- )
1343
+ () -> assertInstallPluginFromUrl (icu , icu , url , false , ".sha512" , checksumAndFilename (digest , url ), newSecretKey (), signature )
1477
1344
);
1478
1345
assertThat (e , hasToString (equalTo ("java.lang.IllegalStateException: signature verification for [" + url + "] failed" )));
1479
1346
}
0 commit comments