Skip to content

Commit 5a76a1b

Browse files
committed
Fix tests regarding security
1 parent bc5a610 commit 5a76a1b

File tree

1 file changed

+8
-26
lines changed

1 file changed

+8
-26
lines changed

modules/swagger-codegen/src/test/java/io/swagger/codegen/DefaultGeneratorTest.java

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -58,23 +58,14 @@ public void testSecurityWithoutGlobal() throws Exception {
5858
gen.opts(clientOptInput);
5959
Map<String, List<CodegenOperation>> paths = gen.processPaths(swagger.getPaths());
6060

61-
CodegenSecurity cs, apiKey, petstoreAuth;
61+
CodegenSecurity apiKey, petstoreAuth;
6262

63-
// security of "getPetById": api_key, petstore_auth
63+
// security of "getPetById": api_key
6464
CodegenOperation getPetById = findCodegenOperationByOperationId(paths, "getPetById");
65-
assertEquals(getPetById.authMethods.size(), 2);
66-
cs = getPetById.authMethods.get(0);
67-
if ("api_key".equals(cs.name)) {
68-
apiKey = cs;
69-
petstoreAuth = getPetById.authMethods.get(1);
70-
} else {
71-
petstoreAuth = cs;
72-
apiKey = getPetById.authMethods.get(1);
73-
}
65+
assertEquals(getPetById.authMethods.size(), 1);
66+
apiKey = getPetById.authMethods.iterator().next();
7467
assertEquals(apiKey.name, "api_key");
7568
assertEquals(apiKey.type, "apiKey");
76-
assertEquals(petstoreAuth.name, "petstore_auth");
77-
assertEquals(petstoreAuth.type, "oauth2");
7869

7970
// security of "updatePetWithForm": petstore_auth
8071
CodegenOperation updatePetWithForm = findCodegenOperationByOperationId(paths, "updatePetWithForm");
@@ -99,23 +90,14 @@ public void testSecurityWithGlobal() throws Exception {
9990
gen.opts(clientOptInput);
10091
Map<String, List<CodegenOperation>> paths = gen.processPaths(swagger.getPaths());
10192

102-
CodegenSecurity cs, apiKey, petstoreAuth;
93+
CodegenSecurity apiKey, petstoreAuth;
10394

104-
// security of "getPetById": api_key, petstore_auth
95+
// security of "getPetById": api_key
10596
CodegenOperation getPetById = findCodegenOperationByOperationId(paths, "getPetById");
106-
assertEquals(getPetById.authMethods.size(), 2);
107-
cs = getPetById.authMethods.get(0);
108-
if ("api_key".equals(cs.name)) {
109-
apiKey = cs;
110-
petstoreAuth = getPetById.authMethods.get(1);
111-
} else {
112-
petstoreAuth = cs;
113-
apiKey = getPetById.authMethods.get(1);
114-
}
97+
assertEquals(getPetById.authMethods.size(), 1);
98+
apiKey = getPetById.authMethods.iterator().next();
11599
assertEquals(apiKey.name, "api_key");
116100
assertEquals(apiKey.type, "apiKey");
117-
assertEquals(petstoreAuth.name, "petstore_auth");
118-
assertEquals(petstoreAuth.type, "oauth2");
119101

120102
// security of "updatePetWithForm": petstore_auth
121103
CodegenOperation updatePetWithForm = findCodegenOperationByOperationId(paths, "updatePetWithForm");

0 commit comments

Comments
 (0)