Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for security header html2 generator #10327

Merged
merged 1 commit into from
Jun 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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