@@ -90,7 +90,7 @@ public void testSecurityWithGlobal() throws Exception {
90
90
gen .opts (clientOptInput );
91
91
Map <String , List <CodegenOperation >> paths = gen .processPaths (swagger .getPaths ());
92
92
93
- CodegenSecurity apiKey , petstoreAuth ;
93
+ CodegenSecurity cs , apiKey , apiKey2 , petstoreAuth ;
94
94
95
95
// security of "getPetById": api_key
96
96
CodegenOperation getPetById = findCodegenOperationByOperationId (paths , "getPetById" );
@@ -106,16 +106,41 @@ public void testSecurityWithGlobal() throws Exception {
106
106
assertEquals (petstoreAuth .name , "petstore_auth" );
107
107
assertEquals (petstoreAuth .type , "oauth2" );
108
108
109
- // security of "loginUser": api_key (from global security)
109
+ // security of "loginUser": api_key, petstore_auth (from global security)
110
110
CodegenOperation loginUser = findCodegenOperationByOperationId (paths , "loginUser" );
111
- assertEquals (loginUser .authMethods .size (), 1 );
112
- apiKey = loginUser .authMethods .iterator ().next ();
111
+ assertEquals (loginUser .authMethods .size (), 2 );
112
+ cs = loginUser .authMethods .get (0 );
113
+ if ("api_key" .equals (cs .name )) {
114
+ apiKey = cs ;
115
+ petstoreAuth = loginUser .authMethods .get (1 );
116
+ } else {
117
+ petstoreAuth = cs ;
118
+ apiKey = loginUser .authMethods .get (1 );
119
+ }
113
120
assertEquals (apiKey .name , "api_key" );
114
121
assertEquals (apiKey .type , "apiKey" );
122
+ assertEquals (petstoreAuth .name , "petstore_auth" );
123
+ assertEquals (petstoreAuth .type , "oauth2" );
115
124
116
125
// security of "logoutUser": null (override global security)
117
126
CodegenOperation logoutUser = findCodegenOperationByOperationId (paths , "logoutUser" );
118
127
assertNull (logoutUser .authMethods );
128
+
129
+ // security of "getUserByName": api_key, api_key2 (override global security)
130
+ CodegenOperation getUserByName = findCodegenOperationByOperationId (paths , "getUserByName" );
131
+ assertEquals (getUserByName .authMethods .size (), 2 );
132
+ cs = getUserByName .authMethods .get (0 );
133
+ if ("api_key" .equals (cs .name )) {
134
+ apiKey = cs ;
135
+ apiKey2 = getUserByName .authMethods .get (1 );
136
+ } else {
137
+ apiKey2 = cs ;
138
+ apiKey = getUserByName .authMethods .get (1 );
139
+ }
140
+ assertEquals (apiKey .name , "api_key" );
141
+ assertEquals (apiKey .type , "apiKey" );
142
+ assertEquals (apiKey2 .name , "api_key2" );
143
+ assertEquals (apiKey2 .type , "apiKey" );
119
144
}
120
145
121
146
@ Test
0 commit comments