Skip to content

Commit

Permalink
Merge pull request #10327 from swagger-api/html2BearerAuth
Browse files Browse the repository at this point in the history
fix for security header html2 generator
  • Loading branch information
gracekarina authored Jun 18, 2020
2 parents 122b5ef + 8a8efcf commit 0708816
Show file tree
Hide file tree
Showing 2 changed files with 409 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,39 @@

public class GeneratorServiceTest {

@Test(description = "test generator service with html2")
public void testGeneratorService_HTML2_Bearer() throws IOException {

String path = getTmpFolder().getAbsolutePath();
GenerationRequest request = new GenerationRequest();
request
.codegenVersion(GenerationRequest.CodegenVersion.V3)
.type(GenerationRequest.Type.CLIENT)
.lang("html2")
.spec(loadSpecAsNode("3_0_0/html2BearerAuthIssue.yaml", true, false))
.options(
new Options()
.outputDir(path)
);
List<File> files = new GeneratorService().generationRequest(request).generate();
Assert.assertFalse(files.isEmpty());
for (File f: files) {
String relPath = f.getAbsolutePath().substring(path.length());
if ("/index.html".equals(relPath)) {
//api key
Assert.assertTrue(FileUtils.readFileToString(f).contains("curl -X GET\\\n" +
"-H \"api_key: [[apiKey]]\"\\"));
//basic
Assert.assertTrue(FileUtils.readFileToString(f).contains("curl -X POST\\\n" +
" -H \"Authorization: Basic [[basicHash]]\"\\"));
//bearer
Assert.assertTrue(FileUtils.readFileToString(f).contains("curl -X PUT\\\n" +
" -H \"Authorization: Bearer [[accessToken]]\"\\"));
}
}

}

@Test(description = "test generator service with html2")
public void testGeneratorService_HTML2() throws IOException {

Expand Down
Loading

0 comments on commit 0708816

Please sign in to comment.