Commit Graph
82 Commits
Author SHA1 Message Date
Basil Crow 632033d6ad Sort imports (#5732) 2021-09-18 09:39:42 +01:00
offa d37a460c84 Exception tests modernized. 2021-07-13 16:48:11 +02:00
offa 7ff32dcf3b Exception tests modernized and some code cleanup. 2021-07-01 17:14:43 +02:00
Basil CrowandDaniel Beck b8c20c6428 Fix violations of a handful of Error Prone checks (#5519)
Co-authored-by: Daniel Beck <1831569+daniel-beck@users.noreply.github.com>
2021-06-14 16:45:34 +01:00
Stefan Spieker afd748142e removed superfluous throws in tests 2021-05-02 00:16:50 +02:00
Basil Crow 95e85495ca Enable AvoidStarImport Checkstyle check (#5420) 2021-04-28 17:28:39 +08:00
Basil Crow f6378676b1 Add missing @Override annotations (#5430) 2021-04-28 17:28:25 +08:00
Basil Crow 3f53051b0b Test cleanup (#5357) 2021-03-16 08:14:11 +00:00
Basil Crow c7c623d502 Add missing @Test annotations 2020-12-19 12:18:08 -08:00
StefanSpiekerandRaihaan Shouhell 4499ad6ffd Replace deprecated NullOutputStream (#4989)
Co-authored-by: Raihaan Shouhell <raihaanhimself@gmail.com>
2020-10-13 08:10:55 +01:00
Tim Jacomb e9dc2694db JENKINS-41805 Cleanup workspace suffixes (#4824) 2020-07-06 19:37:30 +01:00
Stefan Spieker 820c9b4317 minor test refactoring, mainly to use hamcrest matcher instead of deprecated junit assertThat 2020-04-19 20:45:38 +02:00
Stefan Spieker 4cad1a455f use try with resources instead of try finally 2019-11-15 17:49:05 +01:00
Stefan Spieker 02fa8003c0 simplified assertions and removed unthrown exceptions 2019-10-13 20:42:29 +02:00
Raihaan Shouhell e5d578b617 Use type inference instead of specifying it 2019-10-01 13:30:39 +08:00
Anders Hammar 5c10c6c055 Improved handling when TaskListener is null (#4201) 2019-09-20 09:35:17 +02:00
Josh Soref 5f2535d0fa optimize imports using IntelliJ 2019-03-21 13:00:24 -04:00
Josh Soref acc2da063e [SECURITY-904] Fold tests back into normal files 2019-03-21 11:29:20 -04:00
Matt Sicker a489cc4ee7 Move Windows util code into test sources
Signed-off-by: Matt Sicker <boards@gmail.com>
2019-01-11 15:35:02 -06:00
Matt Sicker c35f3ba75c Add more tests for JENKINS-55448
This also refactors some test calls to mklink into a package-private Util method due to additional tests needing to create junction points.

Signed-off-by: Matt Sicker <boards@gmail.com>
2019-01-11 10:35:57 -06:00
Daniel Beck e992e1153b Merge commit '7250d8b875366ae90fa6aec13b5a5c86720e23a3' into security-master 2018-05-07 14:12:09 +02:00
Matt Sicker e229f37dd9 JENKINS-13128: Preserve copied file permissions and mtime (#3400)
* JENKINS-13128: Preserve copied file permissions and mtime

This fixes a bug where files copied locally do not preserve file permissions or last modification time.

* Use IO utility methods for exception handling

* Fix invalid path exception propagation

* Revert hudson.Util
2018-05-04 15:36:33 -04:00
Daniel Beck 7e6c0637b1 Merge branch 'security-stable-2.89' into security-stable-2.107 2018-04-26 01:20:01 +02:00
Wadeck Follonier 5cf0a77d44 [SECURITY-788] 2018-04-25 23:42:19 +02:00
Larry Singleton 8e78ab1c66 [JENKINS-48227] Use "Files.createTempDirectory" to create temp directory (#3161)
* Use "Files.createTempDirectory" to create temp directory instead
See SonarQube critical vulnerability squid:S2976 (tag: owasp-a9)
https://next.sonarqube.com/sonarqube/coding_rules#rule_key=squid%3AS2976

* [JENKINS-48227]
Creating a utility "static Path toPath(File file) throws IOException" method,
which wraps InvalidPathException to IOException so that it will be checked.
- also fixed public static final reference
- fixed broken test cases
- added new test cases for toPath() and createTempDir()

* Revert back to public static int

* adjustments due to merges

* Add posix check to determine if Posix FileAttributes should be included
in call to Files.createTempDirectory()

* Remove reference to private element

* Updated to use explicit imports
2017-12-22 17:38:57 +01:00
Devin Nusbaum fdccc0e838 [JENKINS-36088] Use NIO implementations of chmod and mode by default (#3135)
* Use NIO for FilePath#chmod and IOUtils#mode

* Add tests for NIO mode and chmod implementations

* Add test, remove new method, and update JavaDoc

* Provide system property to use native implementations of chmod and mode

* Revert unrelated whitespace modification

* Don't remove exception from throws and put imports in original location

* Fix broken JavaDoc links

* Ignore file type bits (above 0o7777) in Util#modeToPermission

* Use octal for constants and don't include file type bits

* Revert unnecessary changes to TarArchiverTest

* Add assertion that non-permission bits are ignored by chmod

* Use NIO copy with StandardCopyOption.COPY_ATTRIBUTES in copyToWithPermissions where possible

* Catch InvalidPathException and convert it to IOException

* Create utility method for File#toPath and use File#createDirectories after review

* Remove useless calls to toAbsolutePath and getAbsoluteFile

* Fix typos and use octal for constant after review

* Add test for behavior of copyToWithPermission with special bits
2017-12-01 10:01:34 +03:00
Devin Nusbaum 52fa4d90b9 [JENKINS-39179] [JENKINS-36088] Always use NIO to create and detect symbolic links and Windows junctions (#3133)
* Always use NIO to detect symlinks

* Make assertion failure message consistent

* Catch NoSuchFileException to keep tests passing

* Make method name more specific and simlify assumption

* Remove obsolete comment and reword the main comment in isSymlink

* Deprecate Kernel32Util#isJunctionOrSymlink

* Use assumptions for junction creation and add messages to assumptions

* Replace deprecated code with recommended alternative

* Add comment explaining call to DosFileAttributes#isOther

* Do not fall back to native code when creating symlinks

* Log FileSystemExceptions when creating symbolic links

* Catch InvalidPathException and rethrow as IOException

* Deprecate Kernel32Utils#createSymbolicLink and #getWin32FileAttributes

* Preserve original logging behavior on Windows and remove useless call to Util#displayIOException
2017-11-16 17:08:10 +01:00
Stephen Connolly f0cd7ae8ff [JENKINS-42934] Avoid using new FileInputStream / new FileOutputStream 2017-03-20 12:50:46 +00:00
Vincent Latombe 0c16c8576b [JENKINS-23507] Make FilePath.installIfNecessaryFrom follow redirects (#2331) 2016-05-13 12:36:45 +02:00
Craig Rodrigues 0611d0788a Remove use of '<' and '>' which cause javadoc errors
Tested with Java 8 and "mvn javadoc:test-javadoc".  Eliminates errors such as:

    [ERROR] java/hudson/os/DCOMSandbox.java:18: error: bad use of '>'
2016-04-06 15:52:04 -07:00
Oleg Nenashev 858849ef42 Noting JENKINS-5253 from https://github.com/jenkinsci/jenkins/pull/1429 2015-10-17 22:26:12 +03:00
Oleg Nenashev 4fd10ed723 Merge pull request #1429 from dominiquebrice/jenkins-5253b
[JENKINS-5253] Allow case insensitive patterns in Artifacts Archiving
2015-10-17 22:15:52 +03:00
Oliver Gondža 3990384257 Do not skip tests silently 2015-10-01 08:58:31 +02:00
Kanstantsin Shautsou bfa6d8be0c Remove hardcode in tar test 2015-08-25 01:09:09 +03:00
Kanstantsin Shautsou 3e187a0264 [FIXED JENKINS-10629] Unbroke stream with new tar implementation.
Causes bytes lost and truncated tar archive.
TarBuffer not used in TarArchiveOutputStream.
2015-08-25 01:09:09 +03:00
Oleg Nenashev 32dca8819c [JENKINS-10629] - Direct unit test for the issue
This test also introduces additional round-trip tests for small files
2015-04-14 18:59:38 +03:00
Dominique 40382c5fc4 [JENKINS-5253] Allow case insensitive patterns in Artifacts Archiving 2015-01-31 19:39:10 -05:00
René Scheibe bd1d6251e0 replace all deprecated @Bug annotations with @Issue 2015-01-07 17:12:21 +01:00
Jesse Glick 1fcee97d2f [FIXED JENKINS-26196] More robust handling of server errors in FilePath.installIfNecessaryFrom. 2014-12-29 14:49:27 -05:00
Jesse Glick babfb832a3 JUnit 4. 2014-12-29 14:00:48 -05:00
Jesse Glick 534328b264 [FIXED JENKINS-25759] Avoid consuming too much memory while running validateAntFileMask.
Not fully solved, since the scannedDirs field can still grow to be large, but at least clearing files/dirsNotIncluded.
Also imposing a 5s timeout on the scan regardless of file count, and defining a user-customizable bound.
2014-11-24 10:37:58 -05:00
Kohsuke Kawaguchi d5c368dd8e Merge branch 'pull-714' 2014-04-19 18:31:09 -07:00
Kohsuke Kawaguchi 1f55b80f18 fixed a test regression 2014-04-03 21:05:31 -07:00
Jesse Glick 15ac490af1 Now that we use Java 6, can finally deprecate IOException2. 2013-11-15 08:19:59 -05:00
Jesse Glick 574fe1409e [FIXED JENKINS-9540] Failure of recursive copy on slave side should be reported.
Instead it was being thrown in a Future that the master did not wait for:
the writing side failed with a closed pipe exception, and this meaningless error was thrown up.
Fixing by waiting for the reading side first, so any error there will be thrown up.
(If there was _also_ an error on the writing side, we would miss it, but typically this will just be the closed stream.)
2013-08-29 16:13:48 -04:00
Jesse Glick b1c82f1e30 stephenc asks to use TODO rather than XXX 2013-06-10 11:53:13 -04:00
kkkon 8a9e1ab59f [FIXED JENKINS-16846] fix logic and add test
FilePath#moveAllChildrenTo faild,
when same name directory exist.

change Void to void, recursive_invoke is internal helper function.

thanks review by jglick
2013-02-21 19:30:36 +09:00
Lars Hvile 35f7653b7b [JENKINS-16215] Avoiding unnecessary downloads in FilePath.installIfNecessaryFrom.
The updated version uses the locally cached timestamp, '.timestamp', to set the
'If-Modified-Since' header. 304 Not Modified responses are dealt with by
aborting the installation.
2012-12-28 14:43:41 +01:00
Erik Lindblad f66e19c072 JENKINS-15418 take shares int account, ignore short paths 2012-10-25 17:18:07 +02:00
Jesse Glick a885cc2179 [FIXED JENKINS-7214] FilePath.validateAntFileMask too slow for /configure. 2012-09-19 16:43:20 -04:00