swagger-api / swagger-api/swagger-codegen
[3.0.x] Tests for swagger-generator fail on windows
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I´m trying to build swagger-codegen from source, but the tests for swagger-generator fail with
ERROR i.s.v.g.u.FileAccessSecurityManager - Exception getting absolute path for file C:\Users\nils-\AppData\Local\Temp\codegen-10411439581359926604\_..\mytemp and/or allowed dir
java.io.IOException: Das System kann den angegebenen Pfad nicht finden
at java.base/java.io.WinNTFileSystem.canonicalize0(Native Method)
at java.base/java.io.WinNTFileSystem.canonicalize(WinNTFileSystem.java:438)
at java.base/java.io.File.getCanonicalPath(File.java:620)
at io.swagger.v3.generator.util.FileAccessSecurityManager.checkWrite(FileAccessSecurityManager.java:33)
at java.base/java.io.File.mkdir(File.java:1325)
at java.base/java.io.File.mkdirs(File.java:1357)
at io.swagger.codegen.AbstractGenerator.writeToFile(AbstractGenerator.java:30)
at io.swagger.codegen.DefaultGenerator.generateSupportingFiles(DefaultGenerator.java:638)
at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:781)
at io.swagger.codegen.v3.service.GeneratorService.generate(GeneratorService.java:50)
at io.swagger.v3.generator.online.GeneratorController.generate(GeneratorController.java:508)
at io.swagger.v3.generator.online.GeneratorController.generate(GeneratorController.java:476)
at io.swagger.v3.generator.online.GeneratorControllerTest.generateBashWithAndWithoutSecurityThreat(GeneratorControllerTest.java:86)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...
followed by
ERROR i.s.v.g.online.GeneratorController - Error generating `bash` code : Could not generate supporting file 'SupportingFile:
templateFile: zsh-completion.mustache
folder:
destinationFilename: _../mytemp/start
'
java.lang.RuntimeException: Could not generate supporting file 'SupportingFile:
templateFile: zsh-completion.mustache
folder:
destinationFilename: _../mytemp/start
and
Caused by: java.lang.SecurityException: Exception getting absolute path for allowed dir C:\Users\nils-\AppData\Local\Temp\ and/or file C:\Users\nils-\AppData\Local\Temp\codegen-10411439581359926604\_..\
mytemp
at io.swagger.v3.generator.util.FileAccessSecurityManager.checkWrite(FileAccessSecurityManager.java:38)
at java.base/java.io.File.mkdir(File.java:1325)
at java.base/java.io.File.mkdirs(File.java:1357)
at io.swagger.codegen.AbstractGenerator.writeToFile(AbstractGenerator.java:30)
at io.swagger.codegen.DefaultGenerator.generateSupportingFiles(DefaultGenerator.java:638)
... 34 common frames omitted
when running mvn clean package. Skipping the tests with -DskipTests does work as a workaround.
Looking through the source code, theres a System.setSecurityManager(new FileAccessSecurityManager()); at line 58 in GeneratorController.java. Deactivating that did remove the SecurityException, but the
ERROR i.s.v.g.online.GeneratorController - Error generating `bash` code : Could not generate supporting file 'SupportingFile:
...
'
java.lang.RuntimeException: Could not generate supporting file 'SupportingFile:
...
were still there.
The codegen-10411439581359926604 folder under Temp/ does exist, so it was able to create it, but the _.. folder from that path does not.
Swagger-codegen version
Tested with tags v3.0.25, v3.0.26 and branch 3.0.0.
Command line used for generation
mvn clean package
Maven 3.6.3
AdoptOpenJDK 11
Steps to reproduce
Run mvn clean package on one of the above mentioned tags/branches.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with GeneratorController.java around line 58 and inspect FileAccessSecurityManager.java, then review GeneratorControllerTest.java around line 86. Run mvn clean package on Windows using the reported Java and Maven versions. Done means the swagger-generator tests complete without the path-related SecurityException or supporting-file generation error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system, operating-systems, testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100