commit 68afdd6cc8def5766c3c8660a78d0ddfb479264b Author: Damian Johnson atagar@torproject.org Date: Thu May 25 10:23:11 2017 -0700
Replace test consensus and cert with real copies
Our cached-consensus was a truncated version of the live network consensus but naturally this invalidates its signatures. Replacing it was a consensus teor graciously provided from Chutney with its authority certs.
This also expands our test coverage a little by adding an additional cert test. I'm not sure why the previous metrics cert test lived with the bridge docs, but the key cert unit tests now include a live and metrics descriptor test. --- test/unit/descriptor/data/cached-certs | 92 +++++++++++ test/unit/descriptor/data/cached-consensus | 176 ++++++--------------- .../descriptor/networkstatus/bridge_document.py | 50 ------ test/unit/descriptor/networkstatus/document_v3.py | 110 ++++++------- .../descriptor/networkstatus/key_certificate.py | 114 +++++++++++++ 5 files changed, 307 insertions(+), 235 deletions(-)
diff --git a/test/unit/descriptor/data/cached-certs b/test/unit/descriptor/data/cached-certs new file mode 100644 index 0000000..5e6025f --- /dev/null +++ b/test/unit/descriptor/data/cached-certs @@ -0,0 +1,92 @@ +dir-key-certificate-version 3 +dir-address 127.0.0.1:7000 +fingerprint BCB380A633592C218757BEE11E630511A485658A +dir-key-published 2017-05-25 04:45:52 +dir-key-expires 2018-05-25 04:45:52 +dir-identity-key +-----BEGIN RSA PUBLIC KEY----- +MIIBigKCAYEAxfTHG1b3Sxe8n3JQ/nIk4+1/chj7+jAyLLK+WrEBiP1vnDxTXMuo +x26ntWEjOaxjtKB12k5wMQW94/KvE754Gn98uQRFBHqLkrS4hUnn4/MqiBQVd2y3 +UtE6KDSRhJZ5LfFH+dCKwu5+695PyJp/pfCUSOyPj0HQbFOnAOqdHPok8dtdfsy0 +LaI7ycpzqAalzgrlwFP5KwwLtL+VapUGN4QOZlIXgL4W5e7OAG42lZhHt0b7/zdt +oIegZM1y8tK2l75ijqsvbetddQcFlnVaYzNwlQAUIZuxJOGfnPfTo+WrjCgrK2ur +ed5NiQMrEbZn5uCUscs+xLlKl4uKW0XXo1EIL45yBrVbmlP6V3/9diTHk64W9+m8 +2G4ToDyH8J7LvnYPsmD0cCaQEceebxYVlmmwgqdORH/ixbeGF7JalTwtWBQYo2r0 +VZAqjRwxR9dri6m1MIpzmzWmrbXghZ1IzJEL1rpB0okA/bE8AUGRx61eKnbI415O +PmO06JMpvkxxAgMBAAE= +-----END RSA PUBLIC KEY----- +dir-signing-key +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEAvzugxJl1gc7BgXarBO5IWejNZC30U1xVjZ/myQTzxtiKkPU0agQh +sPqn4vVsaW6ZnWjJ2pSOq0/jg8WgFyGHGQ9cG8tv2TlpObeb/tI7iANxWx+MXJAh +/CnFDBQ1ifKntJrs2IcRKMivfobqaHAL3Pz93noLWOTQunWjZ8D6kovYvUXe+yUQ +tZEROrmXJx7ZIIJF6BNKYBTc+iEkYtkWlJVs0my7yP/bbS075QyBsr6CfT+O2yU4 +mgIg43QuqcFRbjyUvGI/gap06QNlB6yj8pqeE5rWo++5EpEvMK76fK6ymYuTN2SN +Oil+Fo7qgG8UP/fv0GelSz6Tk7pBoeHJlQIDAQAB +-----END RSA PUBLIC KEY----- +dir-key-crosscert +-----BEGIN ID SIGNATURE----- +Oz+rvXDzlxLgQSb3nS5/4hrHVWgGCy0OnuNmFsyw8bi2eBst5Yj79dQ+D25giZke +81FRGIFU4eS6dshB+pJ+z0hc9ozlRTYh/qevY6l6o0amvuhHyk/cQXrh8oYU9Ihe +XQ1yVItvxC24HENsoGIGbr5uxc85FOcNs+R9qTLYA/56TjvAU4WUje3nTZE1awml +lj/Y6DM7ruMF6UoYJZPTklukZ+XHZg4Z2eE55e/oIaD7bfU/lFWU/alMyTV/J5oT +sxaD2XBLBScYiKypUmgrZ50W4ZqsXaYk76ClrudZnDbce+FuugVxok+jKYGjMu75 +2es2ucuik7iuO7QPdPIXfg== +-----END ID SIGNATURE----- +dir-key-certification +-----BEGIN SIGNATURE----- +I86FTQ5ZyCZUzm19HVAQWByrrRgUmddoRBfNiCj0iTGN3kdIq9OfuNLhWAqz71xP +8Nn0Vun8Uj3/vBq/odIFpnngL3mKI6OEKcNDr0D5hEV9Yjrxe8msMoaUZT+LHzUW +1q3pzxfMx6EmlSilMhuzSsa4YEbXMZzMqASKANSJHo2fzUkzQOpPw2SlWSTIgyqw +wAOB6QOvFfP3c0NTwxXrYE/iT+r90wZBuzS+v7r9B94alNAkE1KZQKnq2QTTIznP +iF9LWMsZcMHCjoTxszK4jF4MRMN/S4Xl8yQo0/z6FoqBz4RIXzFtJoG/rbXdKfkE +nJK9iEhaZbS1IN0o+uIGtvOm2rQSu9gS8merurr5GDSK3szjesPVJuF00mCNgOx4 +hAYPN9N8HAL4zGE/l1UM7BGg3L84A0RMpDxnpXePd9mlHLhl4UV2lrkkf8S9Z6fX +PPc3r7zKlL/jEGHwz+C7kE88HIvkVnKLLn//40b6HxitHSOCkZ1vtp8YyXae6xnU +-----END SIGNATURE----- +dir-key-certificate-version 3 +dir-address 127.0.0.1:7001 +fingerprint 596CD48D61FDA4E868F4AA10FF559917BE3B1A35 +dir-key-published 2017-05-25 04:45:58 +dir-key-expires 2018-05-25 04:45:58 +dir-identity-key +-----BEGIN RSA PUBLIC KEY----- +MIIBigKCAYEAu+wP/sAA3tcKI5ICHUTs4uwsqSPNcFDalL7VR9/N4dsgsNd5t+4Z +4v1lc/RovxYC0ojLqe9WE+SsB0cpSRBGA4xSQMOKj3zR1gIO7LQmv2IxYruRlkNo +CxJglbFQOF7gnOOAALygyPl7T5y6BfAeqI9Y51JeHqrgL+7pxAGJ1hNCux4bsAFx +MwNxydBeGS3/yJFp+xJiZl6ocmi9oAmJ4OZmrwKCFTit2Yq5jgbHDkY0OZR6ul8b +xCJRKBSl7jGUhLi1MlW0oGQauKnJ3C/N5rP1icvPJbgP5aZVLqSXFFEGTbjDyFiP +AjlyCozL/A7evAwo1JtxbtBNVCmzUUItP5kd4+YQnYvmH8fRp17JMxLwWLNe0hSx +suljZDdxgCWruTQz8EC73LcExkPQxTb+FUQ3EDm0uGi2A1PUR8+Xtc7fejwov6PN +XtrB+VSn8ne1oA6nI2SS6aNpn1MgAdahvfkTn1c9h2UEhTAeGacvmPLS0YRDdGrs +0ZvQF6Y6694tAgMBAAE= +-----END RSA PUBLIC KEY----- +dir-signing-key +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEA19hY+t1GAsR08rQeqMy8/0XkBx6Ho3WN1XAmHvwkWgnIzamgXJge +THuTw/uDonGXn69NBpQWb9wVyCQ5gssjJCC4OX4EjeZaaxhtZCph3BxA0xHDMYzu +0j/zlXEpQ3Y/05ZbXcJC/VO9QVywwg3QTiTVRjhyD514UeeOxHHJ8JAm5x3puabt +FinwLi3pZBzGisTcfxfpTcZETG47mxzrRTk1KLOU0dvp0UZAdfYQfoecBrWpowCG +dt+kuCK+aUVPi+VbJXK4DzhyaU1nFxHCEEDEfAI7jSt0bdvnTTkVZuoE6JvzIsPn +18qLqG64dgiTs/zutg1Je+NRG3fw5bjg3QIDAQAB +-----END RSA PUBLIC KEY----- +dir-key-crosscert +-----BEGIN ID SIGNATURE----- +A8uI+g1fqMDwfRe7mILD9uDZXgjWc2PaZHElp21wfC5z/fO7EZHf+oBpMfnFZlpW +EgbdIWoxIWAeFiunpUEaGrNGztfXXzmCGJOCkYJS0z6QnbdTPxfARIcQL96NRJ5O +xA0xjTzoR57LKnwHSAdq9ZIjMWyJM7yf/PnD4GCU+v+0O3DzhCPt2vE7QVx6h8oU +Zkmx2GIoRv1K17B0mYJsMFnJse3aLkZdQoFRpicfWwKHtkpGB0dkuGw+OAdcx5vv +Qwb05YiQeAJF3UtPNEcCDR4v5Keia+qQeuJcta9aK2Za/n8LCaB8JrOtDrkMH7EV +DuuXUlxdZG65y9QR3jo5Ng== +-----END ID SIGNATURE----- +dir-key-certification +-----BEGIN SIGNATURE----- +l9Wa0CUIndYdX3nvMEZPoQX8jWosfNo5lTvA1r1JndNBhpr4D6rR9MmpNiaOzuM/ +rcVCMwmekmPVVx2vU168PNX/1yhE0vGEfeRDpiYVXUvboPe2MC9XtUQtQEpmqPrh +EnsfqOhUoxe6uemJszEtqUzHFvcSEUIJN+RX1YG/xGUYsNy5wBZpAMcKiEq0J3c/ +eCrmKs7o4HL/yPtPGdylsMiIhxLmzB1ZjSOq6OpaMPsiafIG+lu0w3G1JAZftCFQ +x+SnFdaxBjeSPlXA8YpIf4SAOx0lSjlcGc+cVUtJcQ2pH01z5s8kMLd7Rei6/Sk7 +xWuiMAqmvG+McfG0C9jhkTp8r6O34zgRTq9sVeZNW/4bn/Nt8vPE8IX9StmGSOju +XA1DuwMEqH1/b5RN5qxWZlvcguEF4CPOh2KNz4M7gsPyc/57eKuvLUSGDtryG0KQ +0FgHa31RRfaO6rIKZ2z2ksHe+bHJi8SM6S9R1KFtudJX4drqTw+Q5q0JRPsKBcGu +-----END SIGNATURE----- diff --git a/test/unit/descriptor/data/cached-consensus b/test/unit/descriptor/data/cached-consensus index adcf13b..4da44cc 100644 --- a/test/unit/descriptor/data/cached-consensus +++ b/test/unit/descriptor/data/cached-consensus @@ -1,130 +1,58 @@ network-status-version 3 vote-status consensus -consensus-method 12 -valid-after 2012-07-12 10:00:00 -fresh-until 2012-07-12 11:00:00 -valid-until 2012-07-12 13:00:00 -voting-delay 300 300 -client-versions 0.2.2.35,0.2.2.36,0.2.2.37,0.2.3.10-alpha,0.2.3.11-alpha,0.2.3.12-alpha,0.2.3.13-alpha,0.2.3.14-alpha,0.2.3.15-alpha,0.2.3.16-alpha,0.2.3.17-beta,0.2.3.18-rc,0.2.3.19-rc -server-versions 0.2.2.35,0.2.2.36,0.2.2.37,0.2.3.10-alpha,0.2.3.11-alpha,0.2.3.12-alpha,0.2.3.13-alpha,0.2.3.14-alpha,0.2.3.15-alpha,0.2.3.16-alpha,0.2.3.17-beta,0.2.3.18-rc,0.2.3.19-rc -known-flags Authority BadExit Exit Fast Guard HSDir Named Running Stable Unnamed V2Dir Valid -params CircuitPriorityHalflifeMsec=30000 bwauthpid=1 -dir-source tor26 14C131DFC5C6F93646BE72FA1401C02A8DF2E8B4 86.59.21.38 86.59.21.38 80 443 -contact Peter Palfrader -vote-digest 0B6D1E9A300B895AA2D0B427F92917B6995C3C1C -dir-source turtles 27B6B5996C426270A5C95488AA5BCEB6BCC86956 76.73.17.194 76.73.17.194 9030 9090 -contact Mike Perry <mikeperryTAfsckedTODorg> -vote-digest 904B1974B9879D02B4ADFB81D7E9B4E07D768A5A -dir-source maatuska 49015F787433103580E3B66A1707A00E60F2D15B 171.25.193.9 171.25.193.9 443 80 -contact 4096R/23291265 Linus Nordberg linus@nordberg.se -vote-digest A8839355BAC373320B8CEDD0A0A09DAAA1637E3A -dir-source dannenberg 585769C78764D58426B8B52B6651A5A71137189A dannenberg.ccc.de 193.23.244.244 80 443 -contact Andreas Lehner anonymizer@ccc.de -vote-digest 416B73C49E717B0A5D61A4F634DCCF94611802E7 -dir-source urras 80550987E1D626E3EBA5E5E75A458DE0626D088C 208.83.223.34 208.83.223.34 443 80 -contact 4096R/E012B42D Jacob Appelbaum jacob@appelbaum.net -vote-digest 08B1F8E4910F136E7FB7DFD52ABB2A9EDE939F0B -dir-source moria1 D586D18309DED4CD6D57C18FDB97EFA96D330566 128.31.0.34 128.31.0.34 9131 9101 -contact 1024D/28988BF5 arma mit edu -vote-digest 5006931FB78F7AE42B602697591DBA82AACEF533 -dir-source dizum E8A9C45EDE6D711294FADF8E7951F4DE6CA56B58 194.109.206.212 194.109.206.212 80 443 -contact 1024R/8D56913D Alex de Joode adejoode@sabotage.org -vote-digest 3F1F1E071EC5F54115CB8EA9723E30A9386AB8CA -dir-source gabelmoo ED03BB616EB2F60BEC80151114BB25CEF515B226 212.112.245.170 212.112.245.170 80 443 -contact 4096R/C5AA446D Sebastian Hahn tor@sebastianhahn.net -vote-digest DF2EC9AD207831DED1D01BB889A9C4478DE2CFB9 -r sumkledi ABPSI4nNUNC3hKPkBhyzHozozrU 8mCr8Sl7RF4ENU4jb0FZFA/3do8 2012-07-12 04:01:55 178.218.213.229 80 0 -s Exit Fast Named Running Valid -v Tor 0.2.2.35 -w Bandwidth=38 -p accept 80,443 -r Unnamed AEXri4INxBAZeyi0wvJZoC58nZs 9t4U465paxGASh0x5Tds8a8YiKo 2012-07-12 04:48:09 79.139.135.90 443 22 -s Fast HSDir Running V2Dir Valid -v Tor 0.2.2.37 -w Bandwidth=35 +consensus-method 26 +valid-after 2017-05-25 04:46:30 +fresh-until 2017-05-25 04:46:40 +valid-until 2017-05-25 04:46:50 +voting-delay 2 2 +client-versions +server-versions +known-flags Authority Exit Fast Guard HSDir NoEdConsensus Running Stable V2Dir Valid +recommended-client-protocols Cons=1-2 Desc=1-2 DirCache=1 HSDir=1 HSIntro=3 HSRend=1 Link=4 LinkAuth=1 Microdesc=1-2 Relay=2 +recommended-relay-protocols Cons=1-2 Desc=1-2 DirCache=1 HSDir=1 HSIntro=3 HSRend=1 Link=4 LinkAuth=1 Microdesc=1-2 Relay=2 +required-client-protocols Cons=1-2 Desc=1-2 DirCache=1 HSDir=1 HSIntro=3 HSRend=1 Link=4 LinkAuth=1 Microdesc=1-2 Relay=2 +required-relay-protocols Cons=1 Desc=1 DirCache=1 HSDir=1 HSIntro=3 HSRend=1 Link=3-4 LinkAuth=1 Microdesc=1 Relay=1-2 +dir-source test001a 596CD48D61FDA4E868F4AA10FF559917BE3B1A35 127.0.0.1 127.0.0.1 7001 5001 +contact auth1@test.test +vote-digest 2E7177224BBA39B505F7608FF376C07884CF926F +dir-source test000a BCB380A633592C218757BEE11E630511A485658A 127.0.0.1 127.0.0.1 7000 5000 +contact auth0@test.test +vote-digest 5DD41617166FFB82882A117EEFDA0353A2794DC5 +r test002r NIIl+DyFR5ay3WNk5lyxibM71pY UzQp+EE8G0YCKtNlZVy+3h5tv0Q 2017-05-25 04:46:11 127.0.0.1 5002 7002 +s Exit Fast Guard HSDir Running Stable V2Dir Valid +v Tor 0.3.0.7 +pr Cons=1-2 Desc=1-2 DirCache=1 HSDir=1-2 HSIntro=3-4 HSRend=1-2 Link=1-4 LinkAuth=1,3 Microdesc=1-2 Relay=1-2 +w Bandwidth=0 Unmeasured=1 +p accept 1-65535 +r test001a qgzRpIKSW809FnL4tntRtWgOiwo x8yR5mi/DBbLg46qwGQ96Dno+nc 2017-05-25 04:46:12 127.0.0.1 5001 7001 +s Authority Exit Fast Guard HSDir Running V2Dir Valid +v Tor 0.3.0.7 +pr Cons=1-2 Desc=1-2 DirCache=1 HSDir=1-2 HSIntro=3-4 HSRend=1-2 Link=1-4 LinkAuth=1,3 Microdesc=1-2 Relay=1-2 +w Bandwidth=0 Unmeasured=1 p reject 1-65535 -r ANONIONROUTER AHhuQ8zFQJdT8l42Axxc6m6kNwI uI7+jQ/T3kFVnl7H7TYE/7WJxi4 2012-07-12 04:40:31 93.128.55.236 24051 24052 -s Fast Named Running V2Dir Valid -v Tor 0.2.2.37 -w Bandwidth=108 -p reject 1-65535 -r ph3x AMLCoWrttR1eX7fWFo/GazQ9gi8 ZJJnmKK6+9B2KOUSIPV49+Vprxs 2012-07-11 19:44:22 86.59.119.83 443 80 -s Fast Guard HSDir Named Running Stable V2Dir Valid -v Tor 0.2.3.18-rc -w Bandwidth=55300 -p reject 1-65535 -r nargothrond ANi/r5RGhUxfZ3simlDXFrf2O68 DsP6REKOns/vAUYNp3rfkCOSJFM 2012-07-11 18:25:37 173.11.83.10 9001 0 -s Fast Guard Named Running Stable Valid -v Tor 0.2.3.18-rc -w Bandwidth=543 -p reject 1-65535 -r default AN1sc6ymJ4WcSJ95VITqL0B5wDQ I9HQ2zph5Nuvf4FKANoKDf5vPV8 2012-07-11 18:48:22 82.243.60.52 443 9030 -s Fast Running V2Dir Valid -v Tor 0.2.2.35 -w Bandwidth=92 -p reject 1-65535 -r catfesh AOTNBUkB8Lob/wiz7h9gtuDoT2Q 0Ycp54MgG+Ns+oEd3BIubFJdGGw 2012-07-12 08:26:51 80.177.151.82 9001 9030 -s Fast HSDir Running V2Dir Valid -v Tor 0.2.2.37 -w Bandwidth=61 -p reject 1-65535 -r 111111 AO70G2tKrAacjjIITtSmzAFrSs8 l/yzMBbM4crBHivPKh69pDXuTRM 2012-07-12 04:03:06 178.170.144.91 80 0 -s Exit Fast Named Running Valid -v Tor 0.2.2.34 -w Bandwidth=29 -p accept 80,443 -r Unnamed AP1onm4+6g+gIQMs1u9r6CeLX80 HY8Ud5ffEX28pglH+Vqvfle1xDQ 2012-07-12 09:09:15 189.41.71.79 443 0 -s Running Valid -v Tor 0.2.2.37 -w Bandwidth=0 +r test000a 3nJC+LvtNmx6kw23x1WE90pyIj4 Hg3NyPqDZoRQN8hVI5Vi6B+pofw 2017-05-25 04:46:12 127.0.0.1 5000 7000 +s Authority Exit Fast Guard HSDir Running Stable V2Dir Valid +v Tor 0.3.0.7 +pr Cons=1-2 Desc=1-2 DirCache=1 HSDir=1-2 HSIntro=3-4 HSRend=1-2 Link=1-4 LinkAuth=1,3 Microdesc=1-2 Relay=1-2 +w Bandwidth=0 Unmeasured=1 p reject 1-65535 directory-footer -bandwidth-weights Wbd=3335 Wbe=0 Wbg=3536 Wbm=10000 Wdb=10000 Web=10000 Wed=3329 Wee=10000 Weg=3329 Wem=10000 Wgb=10000 Wgd=3335 Wgg=6464 Wgm=6464 Wmb=10000 Wmd=3335 Wme=0 Wmg=3536 Wmm=10000 -directory-signature 14C131DFC5C6F93646BE72FA1401C02A8DF2E8B4 BF112F1C6D5543CFD0A32215ACABD4197B5279AD ------BEGIN SIGNATURE----- -HFXB4497LzESysYJ/4jJY83E5vLjhv+igIxD9LU6lf6ftkGeF+lNmIAIEKaMts8H -mfWcW0b+jsrXcJoCxV5IrwCDF3u1aC3diwZY6yiG186pwWbOwE41188XI2DeYPwE -I/TJmV928na7RLZe2mGHCAW3VQOvV+QkCfj05VZ8CsY= ------END SIGNATURE----- -directory-signature 27B6B5996C426270A5C95488AA5BCEB6BCC86956 D5C30C15BB3F1DA27669C2D88439939E8F418FCF ------BEGIN SIGNATURE----- -VAL+VWqcJiJtTZjFDz5/rS4WLfh8dOSnU2HYUb1ZgqM8PR1rFsoxpvaK9USrtkx9 -Byctu/flD3YOqGg+GpYQwU8w9tm7BGelD+dqg97DkJXmlPaXe/Z0nKW1UnCN9m93 -svyWCAqglEzxlK4H7ZfMlQbkMu7EFjXGzrn1gRVGOwg= ------END SIGNATURE----- -directory-signature 49015F787433103580E3B66A1707A00E60F2D15B 1C915B9493589F97BAC764D1885A34BFC18C7E26 ------BEGIN SIGNATURE----- -fHAC5vdqotMtTVIxfqoNrlob2jAi3PP/urvsVA0xmaOzgYtJFIjY2iEWrrU4fRwe -0M1vyCw+oztBrPKYukedkefE9ly/R30KVW2ezo5WpOO4y6oZpelb/jRKFoSRfbyB -WdKsHSe2xlXPA0ySu1klpuMOZiQ8wgxh4x3oLGXnL5Q= ------END SIGNATURE----- -directory-signature 585769C78764D58426B8B52B6651A5A71137189A 499D7CE5A1356045D629F43271EBF600D6F2CC9C ------BEGIN SIGNATURE----- -IDOUDykw+tdCyyVmPSGUDahIeEEPMWxarEoH2gPuyExDqZkUc0ah6Eh736rVSD5Z -R4nCjDNTQNr5byDfJk6cMDN9A/5P8uz421pnmLfs9SasLUjTdJt921jxJnSvSBeF -hSZPNi5wl++Uw3j2zeclOXvAkkAEGi9Pi5Zf6QNlWFI= ------END SIGNATURE----- -directory-signature 80550987E1D626E3EBA5E5E75A458DE0626D088C 2B9B419BB44728A5BE01651D6D1553FD14B6CFFB ------BEGIN SIGNATURE----- -D2wVGni7cYHyXNqt9RvW/CUd8r7TgkfEp9OAJKojUyweiGMJOMEqDBE01e4Ov9Pd -O9D46fjxWYGE9fN72xvD8CGoNcQgTtLpvypEfB96tKM3JYr5j4MCsdcOrQBkKGp7 -qf1Qfiw7aXahk8IfbgvmAvROlAMAxln7nVE0qenQWu4= ------END SIGNATURE----- -directory-signature D586D18309DED4CD6D57C18FDB97EFA96D330566 8F0DEA35D1732D867FB94F5130364927DBCCBB8E ------BEGIN SIGNATURE----- -cmrV1VUfCo9Smlc8BUblkBuSFqJdQkX/gd3ROOnpdRfogbsylq6xA7srCBGp1Z39 -To5Vk71AI0PIy031S6gKfOLgn9E5Bl0Agr60diFxjNn0ejR49MKJTjoDI+DmBlv4 -do+Bej+D8afl27LNH/QIYyzSkOl0eXSGtOEEuCQg/3A= ------END SIGNATURE----- -directory-signature E8A9C45EDE6D711294FADF8E7951F4DE6CA56B58 9BE9A4CF520B6880EB42C5702BC521F03A6CF0FC ------BEGIN SIGNATURE----- -UVXzEFkkjCpszLmoqQxAxSU83IS+fqrkIC4DCQZCEjRcXEvx3c56HUyTsew5WTFR -XANCJn+V3DaxYLuL6L8xW7r9xOQNU970nGwocuJckxyDcLHloL8E226vIAn6mLmt -a1Z6y8NzaQpv4fhdqhT7ETJo+chmf8bSX8qLLmaCIac= ------END SIGNATURE----- -directory-signature ED03BB616EB2F60BEC80151114BB25CEF515B226 845CF1D0B370CA443A8579D18E7987E7E532F639 ------BEGIN SIGNATURE----- -DILsRCrtn6rDbNo3DF+L1/VVAd+V86PdZKg3Q9QooqVOGgU/7HrspV/K4lFbWcTT -Zm+quRQfuKmB4xljwXpeRlABQR5eainlZBtrTFg056/dDrJqYXSwV/C391tAIDZs -2TANs/4uLi94q6Ov+zE9zYUiF8jwnyXl/q/jKOYM8bE= +bandwidth-weights Wbd=3333 Wbe=0 Wbg=0 Wbm=10000 Wdb=10000 Web=10000 Wed=3333 Wee=10000 Weg=3333 Wem=10000 Wgb=10000 Wgd=3333 Wgg=10000 Wgm=10000 Wmb=10000 Wmd=3333 Wme=0 Wmg=0 Wmm=10000 +directory-signature 596CD48D61FDA4E868F4AA10FF559917BE3B1A35 9FBF54D6A62364320308A615BF4CF6B27B254FAD +-----BEGIN SIGNATURE----- +Ho0rLojfLHs9cSPFxe6znuGuFU8BvRr6gnH1gULTjUZO0NSQvo5N628KFeAsq+pT +ElieQeV6UfwnYN1U2tomhBYv3+/p1xBxYS5oTDAITxLUYvH4pLYz09VutwFlFFtU +r/satajuOMST0M3wCCBC4Ru5o5FSklwJTPJ/tWRXDCEHv/N5ZUUkpnNdn+7tFSZ9 +eFrPxPcQvB05BESo7C4/+ZnZVO/wduObSYu04eWwTEog2gkSWmsztKoXpx1QGrtG +sNL22Ws9ySGDO/ykFFyxkcuyB5A8oPyedR7DrJUfCUYyB8o+XLNwODkCFxlmtFOj +ci356fosgLiM1sVqCUkNdA== +-----END SIGNATURE----- +directory-signature BCB380A633592C218757BEE11E630511A485658A 9CA027E05B0CE1500D90DA13FFDA8EDDCD40A734 +-----BEGIN SIGNATURE----- +uiAt8Ir27pYFX5fNKiVZDoa6ELVEtg/E3YeYHAnlSSRzpacLMMTN/HhF//Zvv8Zj +FKT95v77xKvE6b8s7JjB3ep6coiW4tkLqjDiONG6iDRKBmy6D+RZgf1NMxl3gWaZ +ShINORJMW9nglnBbysP7egPiX49w1igVZQLM1C2ppphK6uO5EGcK6nDJF4LVDJ7B +Fvt2yhY+gsiG3oSrhsP0snQnFfvEeUFO/r2gRVJ1FoMXUttaOCtmj268xS08eZ0m +MS+u6gHEM1dYkwpA+LzE9G4akPRhvRjMDaF0RMuLQ7pY5v44uE5OX5n/GKWRgzVZ +DH+ubl6BuqpQxYQXaHZ5iw== -----END SIGNATURE----- diff --git a/test/unit/descriptor/networkstatus/bridge_document.py b/test/unit/descriptor/networkstatus/bridge_document.py index 1ba53e7..d027c94 100644 --- a/test/unit/descriptor/networkstatus/bridge_document.py +++ b/test/unit/descriptor/networkstatus/bridge_document.py @@ -42,56 +42,6 @@ class TestBridgeNetworkStatusDocument(unittest.TestCase): self.assertEqual(443, router.or_port) self.assertEqual(None, router.dir_port)
- def test_metrics_cert(self): - """ - Checks if consensus documents from Metrics are parsed properly. - """ - - expected_identity_key = """-----BEGIN RSA PUBLIC KEY----- -MIIBigKCAYEA7cZXvDRxfjDYtr9/9UsQ852+6cmHMr8VVh8GkLwbq3RzqjkULwQ2 -R9mFvG4FnqMcMKXi62rYYA3fZL1afhT804cpvyp/D3dPM8QxW88fafFAgIFP4LiD -0JYjnF8cva5qZ0nzlWnMXLb32IXSvsGSE2FRyAV0YN9a6k967LSgCfUnZ+IKMezW -1vhL9YK4QIfsDowgtVsavg63GzGmA7JvZmn77+/J5wKz11vGr7Wttf8XABbH2taX -O9j/KGBOX2OKhoF3mXfZSmUO2dV9NMwtkJ7zD///Ny6sfApWV6kVP4O9TdG3bAsl -+fHCoCKgF/jAAWzh6VckQTOPzQZaH5aMWfXrDlzFWg17MjonI+bBTD2Ex2pHczzJ -bN7coDMRH2SuOXv8wFf27KdUxZ/GcrXSRGzlRLygxqlripUanjVGN2JvrVQVr0kz -pjNjiZl2z8ZyZ5d4zQuBi074JPGgx62xAstP37v1mPw14sIWfLgY16ewYuS5bCxV -lyS28jsPht9VAgMBAAE= ------END RSA PUBLIC KEY-----""" - - expected_signing_key = """-----BEGIN RSA PUBLIC KEY----- -MIGJAoGBAOeE3Qr1Km97gTgiB3io0EU0fqHW2ESMXVHeQuNDtCWBa0XSCEG6gx4B -ZkkHjfVWqGQ7TmmzjYP9L9uCgtoKfhSvJA2w9NUMtMl8sgZmF4lcGpXXvGY9a566 -Bn+3wP0lMhb/I8CPVPX+NWEjgl1noZxo1C59SO/iALGQOpxRYgmbAgMBAAE= ------END RSA PUBLIC KEY-----""" - - expected_key_cert = """-----BEGIN SIGNATURE----- -asvWwaMq34OfHoWUhAwh4+JDOuEUZJVIHQnedOYfQH8asS2QvW3Ma93OhrwVOC6b -FyKmTJmJsl0MJGiC7tcEOlL6knsKE4CsuIw/PEcu2Rnm+R9zWxQuMYiHvGQMoDxl -giOhLLs4LlzAAJlbfbd3hjF4STVAtTwmxYuIjb1Mq/JfAsx/wH3TLXgVZwj32w9s -zUd9KZwwLzFiiHpC+U7zh6+wRsZfo2tlpmcaP1dTSINgVbdzPJ/DOUlx9nwTCBsE -AQpUx2DpAikwrpw0zDqpQvYulcQlNLWFN/y/PkmiK8mIJk0OBMiQA7JgqWamnnk4 -PwqaGv483LkBF+25JFGJmnUVve3RMc+s61+2kBcjfUMed4QaHkeCMHqlRqpfQVkk -RY22NXCwrJvSMEwiy7acC8FGysqwHRyE356+Rw6TB43g3Tno9KaHEK7MHXjSHwNs -GM9hAsAMRX9Ogqhq5UjDNqEsvDKuyVeyh7unSZEOip9Zr6K/+7VsVPNb8vfBRBjo ------END SIGNATURE-----""" - - cert_path = get_resource('metrics_cert') - - with open(cert_path, 'rb') as cert_file: - cert = next(stem.descriptor.parse_file(cert_file)) - self.assertEqual(3, cert.version) - self.assertEqual(None, cert.address) - self.assertEqual(None, cert.dir_port) - self.assertEqual('14C131DFC5C6F93646BE72FA1401C02A8DF2E8B4', cert.fingerprint) - self.assertEqual(expected_identity_key, cert.identity_key) - self.assertEqual(datetime.datetime(2008, 5, 9, 21, 13, 26), cert.published) - self.assertEqual(datetime.datetime(2009, 5, 9, 21, 13, 26), cert.expires) - self.assertEqual(expected_signing_key, cert.signing_key) - self.assertEqual(None, cert.crosscert) - self.assertEqual(expected_key_cert, cert.certification) - self.assertEqual([], cert.get_unrecognized_lines()) - def test_empty_document(self): """ Parse a document without any router status entries. diff --git a/test/unit/descriptor/networkstatus/document_v3.py b/test/unit/descriptor/networkstatus/document_v3.py index 4bfdc9e..76017fa 100644 --- a/test/unit/descriptor/networkstatus/document_v3.py +++ b/test/unit/descriptor/networkstatus/document_v3.py @@ -71,43 +71,31 @@ class TestNetworkStatusDocument(unittest.TestCase): self.assertEqual(80, router.or_port) self.assertEqual(None, router.dir_port)
- def test_consensus_v3(self): - """ - Checks that version 3 consensus documents are properly parsed. - """ - - # the document's expected client and server versions are the same - expected_versions = [stem.version.Version(v) for v in ( - '0.2.2.35', - '0.2.2.36', - '0.2.2.37', - '0.2.3.10-alpha', - '0.2.3.11-alpha', - '0.2.3.12-alpha', - '0.2.3.13-alpha', - '0.2.3.14-alpha', - '0.2.3.15-alpha', - '0.2.3.16-alpha', - '0.2.3.17-beta', - '0.2.3.18-rc', - '0.2.3.19-rc', - )] + def test_real_consensus(self): + """ + Checks that version 3 consensus documents from chutney can be properly + parsed. + """
expected_flags = set( - ['Authority', 'BadExit', 'Exit', 'Fast', 'Guard', 'HSDir', - 'Named', 'Running', 'Stable', 'Unnamed', 'V2Dir', 'Valid']) + ['Authority', 'Exit', 'Fast', 'Guard', 'HSDir', + 'Running', 'Stable', 'V2Dir', 'Valid', 'NoEdConsensus'])
expected_bandwidth_weights = { - 'Wbd': 3335, 'Wbe': 0, 'Wbg': 3536, 'Wbm': 10000, 'Wdb': 10000, - 'Web': 10000, 'Wed': 3329, 'Wee': 10000, 'Weg': 3329, 'Wem': 10000, - 'Wgb': 10000, 'Wgd': 3335, 'Wgg': 6464, 'Wgm': 6464, 'Wmb': 10000, - 'Wmd': 3335, 'Wme': 0, 'Wmg': 3536, 'Wmm': 10000 + 'Web': 10000, 'Wdb': 10000, 'Weg': 3333, 'Wee': 10000, 'Wed': 3333, + 'Wgd': 3333, 'Wgb': 10000, 'Wgg': 10000, 'Wem': 10000, 'Wbg': 0, + 'Wbd': 3333, 'Wbe': 0, 'Wmm': 10000, 'Wmb': 10000, 'Wgm': 10000, + 'Wbm': 10000, 'Wmg': 0, 'Wme': 0, 'Wmd': 3333 }
- expected_signature = """-----BEGIN SIGNATURE----- -HFXB4497LzESysYJ/4jJY83E5vLjhv+igIxD9LU6lf6ftkGeF+lNmIAIEKaMts8H -mfWcW0b+jsrXcJoCxV5IrwCDF3u1aC3diwZY6yiG186pwWbOwE41188XI2DeYPwE -I/TJmV928na7RLZe2mGHCAW3VQOvV+QkCfj05VZ8CsY= + expected_signature = """\ +-----BEGIN SIGNATURE----- +Ho0rLojfLHs9cSPFxe6znuGuFU8BvRr6gnH1gULTjUZO0NSQvo5N628KFeAsq+pT +ElieQeV6UfwnYN1U2tomhBYv3+/p1xBxYS5oTDAITxLUYvH4pLYz09VutwFlFFtU +r/satajuOMST0M3wCCBC4Ru5o5FSklwJTPJ/tWRXDCEHv/N5ZUUkpnNdn+7tFSZ9 +eFrPxPcQvB05BESo7C4/+ZnZVO/wduObSYu04eWwTEog2gkSWmsztKoXpx1QGrtG +sNL22Ws9ySGDO/ykFFyxkcuyB5A8oPyedR7DrJUfCUYyB8o+XLNwODkCFxlmtFOj +ci356fosgLiM1sVqCUkNdA== -----END SIGNATURE-----"""
with open(get_resource('cached-consensus'), 'rb') as descriptor_file: @@ -118,51 +106,51 @@ I/TJmV928na7RLZe2mGHCAW3VQOvV+QkCfj05VZ8CsY= self.assertEqual(True, document.is_consensus) self.assertEqual(False, document.is_vote) self.assertEqual(False, document.is_microdescriptor) - self.assertEqual(datetime.datetime(2012, 7, 12, 10, 0, 0), document.valid_after) - self.assertEqual(datetime.datetime(2012, 7, 12, 11, 0, 0), document.fresh_until) - self.assertEqual(datetime.datetime(2012, 7, 12, 13, 0, 0), document.valid_until) - self.assertEqual(300, document.vote_delay) - self.assertEqual(300, document.dist_delay) - self.assertEqual(expected_versions, document.client_versions) - self.assertEqual(expected_versions, document.server_versions) + self.assertEqual(datetime.datetime(2017, 5, 25, 4, 46, 30), document.valid_after) + self.assertEqual(datetime.datetime(2017, 5, 25, 4, 46, 40), document.fresh_until) + self.assertEqual(datetime.datetime(2017, 5, 25, 4, 46, 50), document.valid_until) + self.assertEqual(2, document.vote_delay) + self.assertEqual(2, document.dist_delay) + self.assertEqual([], document.client_versions) + self.assertEqual([], document.server_versions) self.assertEqual(expected_flags, set(document.known_flags)) self.assertEqual([], document.packages) - self.assertEqual({'CircuitPriorityHalflifeMsec': 30000, 'bwauthpid': 1}, document.params) + self.assertEqual({}, document.params)
- self.assertEqual(12, document.consensus_method) + self.assertEqual(26, document.consensus_method) self.assertEqual(expected_bandwidth_weights, document.bandwidth_weights) self.assertEqual([], document.consensus_methods) self.assertEqual(None, document.published) self.assertEqual([], document.get_unrecognized_lines())
- router = document.routers['0013D22389CD50D0B784A3E4061CB31E8CE8CEB5'] - self.assertEqual('sumkledi', router.nickname) - self.assertEqual('0013D22389CD50D0B784A3E4061CB31E8CE8CEB5', router.fingerprint) - self.assertEqual('F260ABF1297B445E04354E236F4159140FF7768F', router.digest) - self.assertEqual(datetime.datetime(2012, 7, 12, 4, 1, 55), router.published) - self.assertEqual('178.218.213.229', router.address) - self.assertEqual(80, router.or_port) - self.assertEqual(None, router.dir_port) - self.assertEqual(set(['Exit', 'Fast', 'Named', 'Running', 'Valid']), set(router.flags)) + router = document.routers['348225F83C854796B2DD6364E65CB189B33BD696'] + self.assertEqual('test002r', router.nickname) + self.assertEqual('348225F83C854796B2DD6364E65CB189B33BD696', router.fingerprint) + self.assertEqual('533429F8413C1B46022AD365655CBEDE1E6DBF44', router.digest) + self.assertEqual(datetime.datetime(2017, 5, 25, 4, 46, 11), router.published) + self.assertEqual('127.0.0.1', router.address) + self.assertEqual(5002, router.or_port) + self.assertEqual(7002, router.dir_port) + self.assertEqual(set(['Exit', 'Fast', 'Running', 'Valid', 'V2Dir', 'Guard', 'HSDir', 'Stable']), set(router.flags))
authority = document.directory_authorities[0] - self.assertEqual(8, len(document.directory_authorities)) - self.assertEqual('tor26', authority.nickname) - self.assertEqual('14C131DFC5C6F93646BE72FA1401C02A8DF2E8B4', authority.fingerprint) - self.assertEqual('86.59.21.38', authority.hostname) - self.assertEqual('86.59.21.38', authority.address) - self.assertEqual(80, authority.dir_port) - self.assertEqual(443, authority.or_port) - self.assertEqual('Peter Palfrader', authority.contact) - self.assertEqual('0B6D1E9A300B895AA2D0B427F92917B6995C3C1C', authority.vote_digest) + self.assertEqual(2, len(document.directory_authorities)) + self.assertEqual('test001a', authority.nickname) + self.assertEqual('596CD48D61FDA4E868F4AA10FF559917BE3B1A35', authority.fingerprint) + self.assertEqual('127.0.0.1', authority.hostname) + self.assertEqual('127.0.0.1', authority.address) + self.assertEqual(7001, authority.dir_port) + self.assertEqual(5001, authority.or_port) + self.assertEqual('auth1@test.test', authority.contact) + self.assertEqual('2E7177224BBA39B505F7608FF376C07884CF926F', authority.vote_digest) self.assertEqual(None, authority.legacy_dir_key) self.assertEqual(None, authority.key_certificate)
signature = document.signatures[0] - self.assertEqual(8, len(document.signatures)) + self.assertEqual(2, len(document.signatures)) self.assertEqual('sha1', signature.method) - self.assertEqual('14C131DFC5C6F93646BE72FA1401C02A8DF2E8B4', signature.identity) - self.assertEqual('BF112F1C6D5543CFD0A32215ACABD4197B5279AD', signature.key_digest) + self.assertEqual('596CD48D61FDA4E868F4AA10FF559917BE3B1A35', signature.identity) + self.assertEqual('9FBF54D6A62364320308A615BF4CF6B27B254FAD', signature.key_digest) self.assertEqual(expected_signature, signature.signature)
def test_metrics_vote(self): diff --git a/test/unit/descriptor/networkstatus/key_certificate.py b/test/unit/descriptor/networkstatus/key_certificate.py index a56c74a..4770517 100644 --- a/test/unit/descriptor/networkstatus/key_certificate.py +++ b/test/unit/descriptor/networkstatus/key_certificate.py @@ -13,6 +13,8 @@ from stem.descriptor.networkstatus import ( KeyCertificate, )
+from test.unit.descriptor import get_resource +
class TestKeyCertificate(unittest.TestCase): def test_minimal(self): @@ -34,6 +36,118 @@ class TestKeyCertificate(unittest.TestCase): self.assertTrue(stem.descriptor.CRYPTO_BLOB in certificate.certification) self.assertEqual([], certificate.get_unrecognized_lines())
+ def test_real_certificates(self): + """ + Checks that key certificates from chutney can be properly parsed. + """ + + expected_identity_key = """\ +-----BEGIN RSA PUBLIC KEY----- +MIIBigKCAYEAxfTHG1b3Sxe8n3JQ/nIk4+1/chj7+jAyLLK+WrEBiP1vnDxTXMuo +x26ntWEjOaxjtKB12k5wMQW94/KvE754Gn98uQRFBHqLkrS4hUnn4/MqiBQVd2y3 +UtE6KDSRhJZ5LfFH+dCKwu5+695PyJp/pfCUSOyPj0HQbFOnAOqdHPok8dtdfsy0 +LaI7ycpzqAalzgrlwFP5KwwLtL+VapUGN4QOZlIXgL4W5e7OAG42lZhHt0b7/zdt +oIegZM1y8tK2l75ijqsvbetddQcFlnVaYzNwlQAUIZuxJOGfnPfTo+WrjCgrK2ur +ed5NiQMrEbZn5uCUscs+xLlKl4uKW0XXo1EIL45yBrVbmlP6V3/9diTHk64W9+m8 +2G4ToDyH8J7LvnYPsmD0cCaQEceebxYVlmmwgqdORH/ixbeGF7JalTwtWBQYo2r0 +VZAqjRwxR9dri6m1MIpzmzWmrbXghZ1IzJEL1rpB0okA/bE8AUGRx61eKnbI415O +PmO06JMpvkxxAgMBAAE= +-----END RSA PUBLIC KEY-----""" + + expected_signing_key = """\ +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEAvzugxJl1gc7BgXarBO5IWejNZC30U1xVjZ/myQTzxtiKkPU0agQh +sPqn4vVsaW6ZnWjJ2pSOq0/jg8WgFyGHGQ9cG8tv2TlpObeb/tI7iANxWx+MXJAh +/CnFDBQ1ifKntJrs2IcRKMivfobqaHAL3Pz93noLWOTQunWjZ8D6kovYvUXe+yUQ +tZEROrmXJx7ZIIJF6BNKYBTc+iEkYtkWlJVs0my7yP/bbS075QyBsr6CfT+O2yU4 +mgIg43QuqcFRbjyUvGI/gap06QNlB6yj8pqeE5rWo++5EpEvMK76fK6ymYuTN2SN +Oil+Fo7qgG8UP/fv0GelSz6Tk7pBoeHJlQIDAQAB +-----END RSA PUBLIC KEY-----""" + + expected_crosscert = """\ +-----BEGIN ID SIGNATURE----- +Oz+rvXDzlxLgQSb3nS5/4hrHVWgGCy0OnuNmFsyw8bi2eBst5Yj79dQ+D25giZke +81FRGIFU4eS6dshB+pJ+z0hc9ozlRTYh/qevY6l6o0amvuhHyk/cQXrh8oYU9Ihe +XQ1yVItvxC24HENsoGIGbr5uxc85FOcNs+R9qTLYA/56TjvAU4WUje3nTZE1awml +lj/Y6DM7ruMF6UoYJZPTklukZ+XHZg4Z2eE55e/oIaD7bfU/lFWU/alMyTV/J5oT +sxaD2XBLBScYiKypUmgrZ50W4ZqsXaYk76ClrudZnDbce+FuugVxok+jKYGjMu75 +2es2ucuik7iuO7QPdPIXfg== +-----END ID SIGNATURE-----""" + + expected_key_cert = """\ +-----BEGIN SIGNATURE----- +I86FTQ5ZyCZUzm19HVAQWByrrRgUmddoRBfNiCj0iTGN3kdIq9OfuNLhWAqz71xP +8Nn0Vun8Uj3/vBq/odIFpnngL3mKI6OEKcNDr0D5hEV9Yjrxe8msMoaUZT+LHzUW +1q3pzxfMx6EmlSilMhuzSsa4YEbXMZzMqASKANSJHo2fzUkzQOpPw2SlWSTIgyqw +wAOB6QOvFfP3c0NTwxXrYE/iT+r90wZBuzS+v7r9B94alNAkE1KZQKnq2QTTIznP +iF9LWMsZcMHCjoTxszK4jF4MRMN/S4Xl8yQo0/z6FoqBz4RIXzFtJoG/rbXdKfkE +nJK9iEhaZbS1IN0o+uIGtvOm2rQSu9gS8merurr5GDSK3szjesPVJuF00mCNgOx4 +hAYPN9N8HAL4zGE/l1UM7BGg3L84A0RMpDxnpXePd9mlHLhl4UV2lrkkf8S9Z6fX +PPc3r7zKlL/jEGHwz+C7kE88HIvkVnKLLn//40b6HxitHSOCkZ1vtp8YyXae6xnU +-----END SIGNATURE-----""" + + with open(get_resource('cached-certs'), 'rb') as cert_file: + cert = next(stem.descriptor.parse_file(cert_file, 'dir-key-certificate-3 1.0')) + self.assertEqual(3, cert.version) + self.assertEqual('127.0.0.1', cert.address) + self.assertEqual(7000, cert.dir_port) + self.assertEqual('BCB380A633592C218757BEE11E630511A485658A', cert.fingerprint) + self.assertEqual(expected_identity_key, cert.identity_key) + self.assertEqual(datetime.datetime(2017, 5, 25, 4, 45, 52), cert.published) + self.assertEqual(datetime.datetime(2018, 5, 25, 4, 45, 52), cert.expires) + self.assertEqual(expected_signing_key, cert.signing_key) + self.assertEqual(expected_crosscert, cert.crosscert) + self.assertEqual(expected_key_cert, cert.certification) + self.assertEqual([], cert.get_unrecognized_lines()) + + def test_metrics_certificate(self): + """ + Checks if consensus documents from Metrics are parsed properly. + """ + + expected_identity_key = """-----BEGIN RSA PUBLIC KEY----- +MIIBigKCAYEA7cZXvDRxfjDYtr9/9UsQ852+6cmHMr8VVh8GkLwbq3RzqjkULwQ2 +R9mFvG4FnqMcMKXi62rYYA3fZL1afhT804cpvyp/D3dPM8QxW88fafFAgIFP4LiD +0JYjnF8cva5qZ0nzlWnMXLb32IXSvsGSE2FRyAV0YN9a6k967LSgCfUnZ+IKMezW +1vhL9YK4QIfsDowgtVsavg63GzGmA7JvZmn77+/J5wKz11vGr7Wttf8XABbH2taX +O9j/KGBOX2OKhoF3mXfZSmUO2dV9NMwtkJ7zD///Ny6sfApWV6kVP4O9TdG3bAsl ++fHCoCKgF/jAAWzh6VckQTOPzQZaH5aMWfXrDlzFWg17MjonI+bBTD2Ex2pHczzJ +bN7coDMRH2SuOXv8wFf27KdUxZ/GcrXSRGzlRLygxqlripUanjVGN2JvrVQVr0kz +pjNjiZl2z8ZyZ5d4zQuBi074JPGgx62xAstP37v1mPw14sIWfLgY16ewYuS5bCxV +lyS28jsPht9VAgMBAAE= +-----END RSA PUBLIC KEY-----""" + + expected_signing_key = """-----BEGIN RSA PUBLIC KEY----- +MIGJAoGBAOeE3Qr1Km97gTgiB3io0EU0fqHW2ESMXVHeQuNDtCWBa0XSCEG6gx4B +ZkkHjfVWqGQ7TmmzjYP9L9uCgtoKfhSvJA2w9NUMtMl8sgZmF4lcGpXXvGY9a566 +Bn+3wP0lMhb/I8CPVPX+NWEjgl1noZxo1C59SO/iALGQOpxRYgmbAgMBAAE= +-----END RSA PUBLIC KEY-----""" + + expected_key_cert = """-----BEGIN SIGNATURE----- +asvWwaMq34OfHoWUhAwh4+JDOuEUZJVIHQnedOYfQH8asS2QvW3Ma93OhrwVOC6b +FyKmTJmJsl0MJGiC7tcEOlL6knsKE4CsuIw/PEcu2Rnm+R9zWxQuMYiHvGQMoDxl +giOhLLs4LlzAAJlbfbd3hjF4STVAtTwmxYuIjb1Mq/JfAsx/wH3TLXgVZwj32w9s +zUd9KZwwLzFiiHpC+U7zh6+wRsZfo2tlpmcaP1dTSINgVbdzPJ/DOUlx9nwTCBsE +AQpUx2DpAikwrpw0zDqpQvYulcQlNLWFN/y/PkmiK8mIJk0OBMiQA7JgqWamnnk4 +PwqaGv483LkBF+25JFGJmnUVve3RMc+s61+2kBcjfUMed4QaHkeCMHqlRqpfQVkk +RY22NXCwrJvSMEwiy7acC8FGysqwHRyE356+Rw6TB43g3Tno9KaHEK7MHXjSHwNs +GM9hAsAMRX9Ogqhq5UjDNqEsvDKuyVeyh7unSZEOip9Zr6K/+7VsVPNb8vfBRBjo +-----END SIGNATURE-----""" + + with open(get_resource('metrics_cert'), 'rb') as cert_file: + cert = next(stem.descriptor.parse_file(cert_file)) + self.assertEqual(3, cert.version) + self.assertEqual(None, cert.address) + self.assertEqual(None, cert.dir_port) + self.assertEqual('14C131DFC5C6F93646BE72FA1401C02A8DF2E8B4', cert.fingerprint) + self.assertEqual(expected_identity_key, cert.identity_key) + self.assertEqual(datetime.datetime(2008, 5, 9, 21, 13, 26), cert.published) + self.assertEqual(datetime.datetime(2009, 5, 9, 21, 13, 26), cert.expires) + self.assertEqual(expected_signing_key, cert.signing_key) + self.assertEqual(None, cert.crosscert) + self.assertEqual(expected_key_cert, cert.certification) + self.assertEqual([], cert.get_unrecognized_lines()) + def test_unrecognized_line(self): """ Includes unrecognized content in the descriptor.
tor-commits@lists.torproject.org