Skip to content

Commit 1b36ea6

Browse files
committed
Make private key signing stable
1 parent 5450e4a commit 1b36ea6

File tree

2 files changed

+68
-74
lines changed

2 files changed

+68
-74
lines changed

modules/cli/src/main/scala/scala/cli/commands/publish/Publish.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -876,9 +876,6 @@ object Publish extends ScalaCommand[PublishOptions] with BuildCommandHelpers {
876876
}
877877
}
878878

879-
if (secretKeyPasswordOpt.isEmpty)
880-
logger.diagnostic("PGP signing with no password is not recommended since it's not stable")
881-
882879
if (forceSigningBinary)
883880
(new scala.cli.internal.BouncycastleSignerMakerSubst).get(
884881
secretKeyPasswordOpt.fold(null)(_.toCliSigning),

modules/integration/src/test/scala/scala/cli/integration/PublishTestDefinitions.scala

Lines changed: 68 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -274,91 +274,88 @@ abstract class PublishTestDefinitions(val scalaVersionOpt: Option[String])
274274
}
275275
}
276276

277-
if (!TestUtil.isNativeCli)
278-
test("missing secret key password") {
279-
// format: off
280-
val signingOptions = Seq(
281-
"--secret-key", s"file:key.skr",
282-
"--signer", "bc"
283-
)
284-
// format: on
277+
test("no secret key password") {
278+
// format: off
279+
val signingOptions = Seq(
280+
"--secret-key", s"file:key.skr",
281+
"--signer", "bc"
282+
)
283+
// format: on
285284

286-
TestCase.testInputs.fromRoot { root =>
287-
val confDir = root / "config"
288-
val confFile = confDir / "test-config.json"
285+
TestCase.testInputs.fromRoot { root =>
286+
val confDir = root / "config"
287+
val confFile = confDir / "test-config.json"
289288

290-
os.write(confFile, "{}", createFolders = true)
289+
os.write(confFile, "{}", createFolders = true)
291290

292-
if (!Properties.isWin)
293-
os.perms.set(confDir, "rwx------")
291+
if (!Properties.isWin)
292+
os.perms.set(confDir, "rwx------")
294293

295-
val extraEnv = Map("SCALA_CLI_CONFIG" -> confFile.toString)
294+
val extraEnv = Map("SCALA_CLI_CONFIG" -> confFile.toString)
296295

297-
os.proc(
298-
TestUtil.cli,
299-
"--power",
300-
"pgp",
301-
"create",
302-
"--email",
303-
"some_email",
304-
"--password",
305-
"value:"
306-
).call(cwd = root, env = extraEnv)
296+
os.proc(
297+
TestUtil.cli,
298+
"--power",
299+
"pgp",
300+
"create",
301+
"--email",
302+
"some_email"
303+
).call(cwd = root, env = extraEnv)
307304

308-
val publicKey = os.Path("key.pub", root)
305+
val publicKey = os.Path("key.pub", root)
309306

310-
os.proc(
311-
TestUtil.cli,
312-
"--power",
313-
"publish",
314-
extraOptions,
315-
signingOptions,
316-
"project",
317-
"-R",
318-
"test-repo"
319-
).call(cwd = root, env = extraEnv)
307+
os.proc(
308+
TestUtil.cli,
309+
"--power",
310+
"publish",
311+
extraOptions,
312+
signingOptions,
313+
"project",
314+
"-R",
315+
"test-repo"
316+
).call(cwd = root, env = extraEnv)
320317

321-
val files = os.walk(root / "test-repo")
322-
.filter(os.isFile(_))
323-
.map(_.relativeTo(root / "test-repo"))
324-
val notInDir = files.filter(!_.startsWith(TestCase.expectedArtifactsDir))
325-
expect(notInDir.isEmpty)
318+
val files = os.walk(root / "test-repo")
319+
.filter(os.isFile(_))
320+
.map(_.relativeTo(root / "test-repo"))
321+
val notInDir = files.filter(!_.startsWith(TestCase.expectedArtifactsDir))
322+
expect(notInDir.isEmpty)
326323

327-
val files0 = files.map(_.relativeTo(TestCase.expectedArtifactsDir)).toSet
324+
val files0 = files.map(_.relativeTo(TestCase.expectedArtifactsDir)).toSet
328325

329-
expect((files0 -- expectedArtifacts).isEmpty)
330-
expect((expectedArtifacts -- files0).isEmpty)
331-
expect(files0 == expectedArtifacts) // just in case…
326+
expect((files0 -- expectedArtifacts).isEmpty)
327+
expect((expectedArtifacts -- files0).isEmpty)
328+
expect(files0 == expectedArtifacts) // just in case…
332329

333-
val repoArgs =
334-
Seq[os.Shellable]("-r", "!central", "-r", (root / "test-repo").toNIO.toUri.toASCIIString)
335-
val dep = s"org.virtuslab.scalacli.test:simple${TestCase.scalaSuffix}:0.2.0-SNAPSHOT"
336-
val res = os.proc(TestUtil.cs, "launch", repoArgs, dep).call(cwd = root)
337-
val output = res.out.trim()
338-
expect(output == "Hello")
330+
val repoArgs =
331+
Seq[os.Shellable]("-r", "!central", "-r", (root / "test-repo").toNIO.toUri.toASCIIString)
332+
val dep = s"org.virtuslab.scalacli.test:simple${TestCase.scalaSuffix}:0.2.0-SNAPSHOT"
333+
val res = os.proc(TestUtil.cs, "launch", repoArgs, dep).call(cwd = root)
334+
val output = res.out.trim()
335+
expect(output == "Hello")
339336

340-
val sourceJarViaCsStr =
341-
os.proc(TestUtil.cs, "fetch", repoArgs, "--sources", "--intransitive", dep)
342-
.call(cwd = root)
343-
.out.trim()
344-
val sourceJarViaCs = os.Path(sourceJarViaCsStr, os.pwd)
345-
val zf = new ZipFile(sourceJarViaCs.toIO)
346-
val entries = zf.entries().asScala.toVector.map(_.getName).toSet
347-
expect(entries == expectedSourceEntries)
337+
val sourceJarViaCsStr =
338+
os.proc(TestUtil.cs, "fetch", repoArgs, "--sources", "--intransitive", dep)
339+
.call(cwd = root)
340+
.out.trim()
341+
val sourceJarViaCs = os.Path(sourceJarViaCsStr, os.pwd)
342+
val zf = new ZipFile(sourceJarViaCs.toIO)
343+
val entries = zf.entries().asScala.toVector.map(_.getName).toSet
344+
expect(entries == expectedSourceEntries)
348345

349-
val signatures = expectedArtifacts.filter(_.last.endsWith(".asc"))
350-
assert(signatures.nonEmpty)
351-
os.proc(
352-
TestUtil.cli,
353-
"--power",
354-
"pgp",
355-
"verify",
356-
"--key",
357-
publicKey,
358-
signatures.map(os.rel / "test-repo" / TestCase.expectedArtifactsDir / _)
359-
).call(cwd = root, env = extraEnv)
360-
}
346+
val signatures = expectedArtifacts.filter(_.last.endsWith(".asc"))
347+
assert(signatures.nonEmpty)
348+
os.proc(
349+
TestUtil.cli,
350+
"--power",
351+
"pgp",
352+
"verify",
353+
"--key",
354+
publicKey,
355+
signatures.map(os.rel / "test-repo" / TestCase.expectedArtifactsDir / _)
356+
).call(cwd = root, env = extraEnv)
361357
}
358+
}
362359

363360
if (!Properties.isWin) // TODO: fix intermittent failures on Windows
364361
test("secret keys in config") {

0 commit comments

Comments
 (0)