← Back to team overview

libravatar-fans team mailing list archive

Libravatar tests

 

Hello,

My hand-rolled tests are now converted to sharness as suggested by Lars Kruse, which in my opinion improved them. They are available here:

https://github.com/Aversiste/libravatar.cgi/tree/master/regress

As described in the README curl and sharness need to be installed. The tests should otherwise be easy to run (tell me if they are not !).

There are two test files of interest for us here:

* ivatar.t ;
* libravatar.org.t.

I wrote ivatar.t with what I read in its source code as well as the knowledge of a previous test session I did some time ago, but I haven't tested it effectively as I can't register my email address on avatars.linux-kernet.at (I sent a separate email to Oliver Falk for this issue).

The writing of libravatar.org.t gave me some troubles for a few reasons. As I said during the last meeting it is too permissive as it happily accepts requests for size outside the documented bounds (1-512). A size of 0, or even a negative one, returns a HTTP 200 code and a 1 pixel PNG image. Another issue comes from the systematic redirections to Gravatar, even for trivial requests such as default=404 or default=http://cdn.libravatar.org/nobody.png on a non existing email address. Gravatar caches optimized versions of the avatars it serves, making them hard to compare with their original source. Also some of the tests are marked as “test_expect_failure” as I am not sure what we want to consider acceptable. For my implementation, which is quite strict, I don't allow empty value for the “size” or “default” parameters nor non-integer value such as “size=onehundred”. The official documentation[1] doesn't mention what is acceptable or not so it is up to us to clarify this point.

You can find the output of libravatar.org.t and libravatar.cgi.t (my implementation for comparison) attached.

Regards.

[1]: https://wiki.libravatar.org/api/
ok 1 - OPTIONS on /
ok 2 - POST on /
ok 3 - GET on index
ok 4 - GET on invalid path
ok 5 - GET on /avatar
ok 6 - GET on tleguern@xxxxxxxxxxx's avatar
ok 7 - GET on tleguern@xxxxxxxxxxx's avatar with a size of 200
ok 8 - GET on tleguern@xxxxxxxxxxx's avatar with an empty size
ok 9 - GET on tleguern@xxxxxxxxxxx's avatar with an invalid size
ok 10 - GET on tleguern@xxxxxxxxxxx's avatar with size 0
ok 11 - GET avatar for tleguern@xxxxxxxxxxx with size 1000
ok 12 - GET on tleguern@xxxxxxxxxxx's avatar with an empty default
ok 13 - GET on tleguern@xxxxxxxxxxx's avatar with default=404
ok 14 - GET on tleguern@xxxxxxxxxxx's avatar with default=404 and forcedefault=y
ok 15 - GET on a non existing user's avatar with default=404
ok 16 - GET on a non existing user's avatar with d=$URL (no follow)
ok 17 - GET on a non existing user's avatar with d=$URL (follow)
ok 18 - Size of the fetched avatar should be 80
ok 19 - GET on a non existing user's avatar with d=mm
ok 20 - GET on a non existing user's avatar with d=blank
ok 21 - Size of the fetched blank avatar should be 80
# passed all 21 test(s)
1..21
ok 1 - GET on tleguern@xxxxxxxxxxx's avatar
ok 2 - Size of the fetched avatar should be 80
ok 3 - GET on tleguern@xxxxxxxxxxx's avatar with a size of 200
ok 4 - Size of the fetched avatar should be 200
not ok 5 - GET on tleguern@xxxxxxxxxxx's avatar with an empty size # TODO known breakage
not ok 6 - GET on tleguern@xxxxxxxxxxx's avatar with an invalid size # TODO known breakage
not ok 7 - GET on tleguern@xxxxxxxxxxx's avatar with size 0
#	
#		test_when_finished 'rm -f -- /tmp/libravatar.test.png' && 	testhttpcode GET avatar/4751ed9aae86881d2b45dd0512c3e14a?s=0 400
#	
not ok 8 - GET avatar for tleguern@xxxxxxxxxxx with size 1000
#	
#		test_when_finished 'rm -f -- /tmp/libravatar.test.png' && 	testhttpcode GET avatar/4751ed9aae86881d2b45dd0512c3e14a?s=1000 400
#	
not ok 9 - GET on tleguern@xxxxxxxxxxx's avatar with an empty default # TODO known breakage
ok 10 - GET on tleguern@xxxxxxxxxxx's avatar with default=404
ok 11 - GET on a non existing user's avatar with default=404
ok 12 - GET on a non existing user's avatar with d=$URL (no follow)
ok 13 - GET on a non existing user's avatar with d=$URL (follow)
ok 14 - Size of the fetched avatar should be 80
not ok 15 - The fetched avatar should be nobody.png # TODO known breakage
ok 16 - GET on a non existing user's avatar with d=mm
ok 17 - Size of the fetched mm avatar should be 80
not ok 18 - The fetched avatar should be mm.png # TODO known breakage
ok 19 - GET on a non existing user's avatar with d=identicon
ok 20 - GET on a non existing user's avatar with d=monsterid
ok 21 - GET on a non existing user's avatar with d=wavatar
ok 22 - GET on a non existing user's avatar with d=retro
# still have 5 known breakage(s)
# failed 2 among remaining 17 test(s)
1..22

Follow ups