From 5a76a1b1551f1a83af37f8de32b79b4094c76a2c Mon Sep 17 00:00:00 2001 From: xhh Date: Thu, 15 Oct 2015 16:51:43 +0800 Subject: [PATCH] Fix tests regarding security --- .../swagger/codegen/DefaultGeneratorTest.java | 34 +++++-------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/DefaultGeneratorTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/DefaultGeneratorTest.java index 18a115c6527..2828d8994d7 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/DefaultGeneratorTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/DefaultGeneratorTest.java @@ -58,23 +58,14 @@ public class DefaultGeneratorTest { gen.opts(clientOptInput); Map> paths = gen.processPaths(swagger.getPaths()); - CodegenSecurity cs, apiKey, petstoreAuth; + CodegenSecurity apiKey, petstoreAuth; - // security of "getPetById": api_key, petstore_auth + // security of "getPetById": api_key CodegenOperation getPetById = findCodegenOperationByOperationId(paths, "getPetById"); - assertEquals(getPetById.authMethods.size(), 2); - cs = getPetById.authMethods.get(0); - if ("api_key".equals(cs.name)) { - apiKey = cs; - petstoreAuth = getPetById.authMethods.get(1); - } else { - petstoreAuth = cs; - apiKey = getPetById.authMethods.get(1); - } + assertEquals(getPetById.authMethods.size(), 1); + apiKey = getPetById.authMethods.iterator().next(); assertEquals(apiKey.name, "api_key"); assertEquals(apiKey.type, "apiKey"); - assertEquals(petstoreAuth.name, "petstore_auth"); - assertEquals(petstoreAuth.type, "oauth2"); // security of "updatePetWithForm": petstore_auth CodegenOperation updatePetWithForm = findCodegenOperationByOperationId(paths, "updatePetWithForm"); @@ -99,23 +90,14 @@ public class DefaultGeneratorTest { gen.opts(clientOptInput); Map> paths = gen.processPaths(swagger.getPaths()); - CodegenSecurity cs, apiKey, petstoreAuth; + CodegenSecurity apiKey, petstoreAuth; - // security of "getPetById": api_key, petstore_auth + // security of "getPetById": api_key CodegenOperation getPetById = findCodegenOperationByOperationId(paths, "getPetById"); - assertEquals(getPetById.authMethods.size(), 2); - cs = getPetById.authMethods.get(0); - if ("api_key".equals(cs.name)) { - apiKey = cs; - petstoreAuth = getPetById.authMethods.get(1); - } else { - petstoreAuth = cs; - apiKey = getPetById.authMethods.get(1); - } + assertEquals(getPetById.authMethods.size(), 1); + apiKey = getPetById.authMethods.iterator().next(); assertEquals(apiKey.name, "api_key"); assertEquals(apiKey.type, "apiKey"); - assertEquals(petstoreAuth.name, "petstore_auth"); - assertEquals(petstoreAuth.type, "oauth2"); // security of "updatePetWithForm": petstore_auth CodegenOperation updatePetWithForm = findCodegenOperationByOperationId(paths, "updatePetWithForm");