@@ -144,3 +144,41 @@ def test_load_invalid_cert(self):
144
144
certificate = 'i am bad data' ,
145
145
key = 'i am bad data as well'
146
146
)
147
+
148
+ def test_certs_fetch_limit (self ):
149
+ """
150
+ When a user retrieves a certificate, make sure limits work
151
+ """
152
+ response = self .client .post (
153
+ self .url ,
154
+ {
155
+ 'name' : 'random-test-cert1' ,
156
+ 'certificate' : self .cert ,
157
+ 'key' : self .key
158
+ }
159
+ )
160
+ self .assertEqual (response .status_code , 201 , response .data )
161
+
162
+ response = self .client .post (
163
+ self .url ,
164
+ {
165
+ 'name' : 'random-test-cert2' ,
166
+ 'certificate' : self .cert ,
167
+ 'key' : self .key
168
+ }
169
+ )
170
+ self .assertEqual (response .status_code , 201 , response .data )
171
+
172
+ # limit=0 is invalid as of DRF 3.4
173
+ # https://github.com/tomchristie/django-rest-framework/pull/4194
174
+ response = self .client .get ('{}?limit=0' .format (self .url ))
175
+ self .assertEqual (response .status_code , 200 , response .data )
176
+ self .assertEqual (len (response .data ['results' ]), 2 , 'limit=0 should return 2' )
177
+
178
+ response = self .client .get ('{}?limit=1' .format (self .url ))
179
+ self .assertEqual (response .status_code , 200 , response .data )
180
+ self .assertEqual (len (response .data ['results' ]), 1 , 'limit=1 should return 1' )
181
+
182
+ response = self .client .get (self .url )
183
+ self .assertEqual (response .status_code , 200 , response .data )
184
+ self .assertEqual (len (response .data ['results' ]), 2 )
0 commit comments