From 92713afd1ed327d5b2fbf774c7f393d43337ae0c Mon Sep 17 00:00:00 2001 From: Filippo Valsorda Date: Wed, 15 Jun 2022 20:16:36 +0200 Subject: [PATCH] tests: add scrypt tests and move Go files from testdata --- .gitattributes | 2 +- .../testdata/fail_large_filekey_scrypt.age | Bin 207 -> 0 bytes cmd/age/testdata/fail_scrypt_and_x25519.age | Bin 283 -> 0 bytes .../testdata/fail_scrypt_work_factor_23.age | Bin 185 -> 0 bytes .../testdata/good_scrypt_work_factor_10.age | Bin 185 -> 0 bytes internal/testkit/testkit.go | 37 ++++++++++++++---- testdata/{bad_hmac.test => testkit/bad_hmac} | Bin .../long_file_key} | Bin testdata/testkit/long_file_key_scrypt | Bin 0 -> 377 bytes testdata/testkit/scrypt | Bin 0 -> 340 bytes testdata/testkit/scrypt_and_x25519 | Bin 0 -> 423 bytes testdata/testkit/scrypt_no_match | Bin 0 -> 270 bytes testdata/testkit/scrypt_work_factor_23 | Bin 0 -> 321 bytes .../stanza_empty_body} | Bin .../stanza_empty_last_line} | Bin .../stanza_missing_body} | Bin .../stanza_missing_final_line} | Bin .../stanza_multiple_short_lines} | Bin .../stream_empty_payload} | Bin .../stream_last_chunk_empty} | Bin 66044 -> 65978 bytes .../stream_last_chunk_full} | Bin testdata/testkit/valid_characters | Bin 0 -> 532 bytes testdata/{x25519.test => testkit/x25519} | Bin testdata/testkit/x25519_multiple_recipients | Bin 0 -> 520 bytes .../x25519_no_match} | Bin testkit_test.go | 18 ++++++--- {testdata => tests}/bad_hmac.go | 0 {testdata => tests}/long_file_key.go | 0 tests/long_file_key_scrypt.go | 21 ++++++++++ tests/scrypt.go | 18 +++++++++ tests/scrypt_and_x25519.go | 21 ++++++++++ tests/scrypt_no_match.go | 20 ++++++++++ tests/scrypt_work_factor_23.go | 23 +++++++++++ {testdata => tests}/stanza_empty_body.go | 0 {testdata => tests}/stanza_empty_last_line.go | 0 {testdata => tests}/stanza_missing_body.go | 0 .../stanza_missing_final_line.go | 0 .../stanza_multiple_short_lines.go | 0 {testdata => tests}/stream_empty_payload.go | 0 .../stream_last_chunk_empty.go | 0 {testdata => tests}/stream_last_chunk_full.go | 0 tests/valid_characters.go | 21 ++++++++++ {testdata => tests}/x25519.go | 0 tests/x25519_multiple_recipients.go | 19 +++++++++ .../no_match.go => tests/x25519_no_match.go | 0 45 files changed, 186 insertions(+), 14 deletions(-) delete mode 100644 cmd/age/testdata/fail_large_filekey_scrypt.age delete mode 100644 cmd/age/testdata/fail_scrypt_and_x25519.age delete mode 100644 cmd/age/testdata/fail_scrypt_work_factor_23.age delete mode 100644 cmd/age/testdata/good_scrypt_work_factor_10.age rename testdata/{bad_hmac.test => testkit/bad_hmac} (100%) rename testdata/{long_file_key.test => testkit/long_file_key} (100%) create mode 100644 testdata/testkit/long_file_key_scrypt create mode 100644 testdata/testkit/scrypt create mode 100644 testdata/testkit/scrypt_and_x25519 create mode 100644 testdata/testkit/scrypt_no_match create mode 100644 testdata/testkit/scrypt_work_factor_23 rename testdata/{stanza_empty_body.test => testkit/stanza_empty_body} (100%) rename testdata/{stanza_empty_last_line.test => testkit/stanza_empty_last_line} (100%) rename testdata/{stanza_missing_body.test => testkit/stanza_missing_body} (100%) rename testdata/{stanza_missing_final_line.test => testkit/stanza_missing_final_line} (100%) rename testdata/{stanza_multiple_short_lines.test => testkit/stanza_multiple_short_lines} (100%) rename testdata/{stream_empty_payload.test => testkit/stream_empty_payload} (100%) rename testdata/{stream_last_chunk_empty.test => testkit/stream_last_chunk_empty} (99%) rename testdata/{stream_last_chunk_full.test => testkit/stream_last_chunk_full} (100%) create mode 100644 testdata/testkit/valid_characters rename testdata/{x25519.test => testkit/x25519} (100%) create mode 100644 testdata/testkit/x25519_multiple_recipients rename testdata/{no_match.test => testkit/x25519_no_match} (100%) rename {testdata => tests}/bad_hmac.go (100%) rename {testdata => tests}/long_file_key.go (100%) create mode 100644 tests/long_file_key_scrypt.go create mode 100644 tests/scrypt.go create mode 100644 tests/scrypt_and_x25519.go create mode 100644 tests/scrypt_no_match.go create mode 100644 tests/scrypt_work_factor_23.go rename {testdata => tests}/stanza_empty_body.go (100%) rename {testdata => tests}/stanza_empty_last_line.go (100%) rename {testdata => tests}/stanza_missing_body.go (100%) rename {testdata => tests}/stanza_missing_final_line.go (100%) rename {testdata => tests}/stanza_multiple_short_lines.go (100%) rename {testdata => tests}/stream_empty_payload.go (100%) rename {testdata => tests}/stream_last_chunk_empty.go (100%) rename {testdata => tests}/stream_last_chunk_full.go (100%) create mode 100644 tests/valid_characters.go rename {testdata => tests}/x25519.go (100%) create mode 100644 tests/x25519_multiple_recipients.go rename testdata/no_match.go => tests/x25519_no_match.go (100%) diff --git a/.gitattributes b/.gitattributes index a369d6c..bb7ec5e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,2 @@ *.age binary -*.test binary +testdata/testkit/* binary diff --git a/cmd/age/testdata/fail_large_filekey_scrypt.age b/cmd/age/testdata/fail_large_filekey_scrypt.age deleted file mode 100644 index 4951b647b7ca94d34960cacb0f3b1526fa20274f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 207 zcmYdHPt{G$OD?J`D9Oyv)5|YP*Do{V(zR1428$_FS%g}qMEVAndK;#>rIeKv1V;L} z1}YdDaG3^&WtAHyCAm3A`J{Lnx&@gB6{dxx7*~epn|KEsW@h_ml~tJ;I29CT6qOl- zo8_D78|4>QRYbYw8m7C3I&*R9>gp;)MpOis`}?^EI39NI>U8T@ohV2eP;hXy|iV|W>wEmIqm5hyHep}-V~J+ib?B? E01&xIcK`qY diff --git a/cmd/age/testdata/fail_scrypt_and_x25519.age b/cmd/age/testdata/fail_scrypt_and_x25519.age deleted file mode 100644 index 25f39f0816e16b497a0d47c1af51570fd97111c5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 283 zcmYdHPt{G$OD?J`D9Oyv)5|YP*Do{V(zR2FFfuhYv{Wc?3NDH?EiO)S3NkDAC=My{ z2yo2}Of3(~4vGp(OAAiU4+u5ROe;2V$>;L(O|Hx{E6WN@3QS4N4bsnz@GMM9EYI>v z&j<^0H46%;^m7d=&kZ;9%m&#|47ODv+ux_8L_5jf+anHIpk`1y6%w_`s`RiWt diff --git a/cmd/age/testdata/fail_scrypt_work_factor_23.age b/cmd/age/testdata/fail_scrypt_work_factor_23.age deleted file mode 100644 index 16846b17a5fe3e131db36f638f298dc87693efd1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 185 zcmYdHPt{G$OD?J`D9Oyv)5|YP*Do{V(zR1428$^e2AYNExaSrJmF6V*nJ49jmRmR) z1}YdCbGZi?<>Xblm1Y~Jq`PJ(`v&BCn|WvFmip(KrhA5aRr#crmb)hh6_+_ia_Q>o zDwIW(`4@*Jxg_}}8&sHj6&tz*n`Ik@W%_#=dl*Hf1cyfDTPCHIB~|5ya@l@7dh^hn j#Vg9}c9vy$`~FtHdjHo=*}Zo zDrEa-x(1k)=KEH9Te^FD7KfRe=bPjw29&xM83h`Yr6iYX8wPnh8|V0ha%IfV-xRPU ijJJGw45MkC$(Pr8u6y&Zrq~rR`_J0Im&L^YAB+cuFoAePk-~x0e;s$gD zb|Qjp1KgE-6Ei}v+e<0$D*eLYC&Trs-FC3S;oT$Niml$(JO zPTWq|)%2lBBuRozleTqtkQtG>=Y;d4fcM%;G&POmK&}iX-KwTH;!c0Yxk=X8>&Mmm g%3J-Vc(~8EHZFG7uWy$(%g5){&%4EwShT*r0fGa7TmS$7 literal 0 HcmV?d00001 diff --git a/testdata/testkit/scrypt b/testdata/testkit/scrypt new file mode 100644 index 0000000000000000000000000000000000000000..57dd08f0e7b2312db772e8f24d786de3bb3da187 GIT binary patch literal 340 zcmW-aJ5Iwe06>{DA_k-`W+&8f?8b=%5>zcMC6x5vY>w@uKbkZSZNmk)0}^n79)KN* zGaw{ZHjaQqL2r3_%aiLw^2`D1mUF3;mau#lGvNSem?6O!LQaujkV4b4h|L7Ep~YxG zOIX^LkksIiQf5#DONiruln@F9Vu2QpXA(?h?f_zAg87z^SO^l65R98^`mbIE{)+L(@-y`fnhu!s68`n00HlP7--hE0Lt^ z0Rw7LcT&l3stva{@G1@Ay0uG$Djud`l0UyTq}^bulvuP59c-CJZFaoKl^^+>G)ec?rkOy K*SqdZ`2GvoZEjrv literal 0 HcmV?d00001 diff --git a/testdata/testkit/scrypt_and_x25519 b/testdata/testkit/scrypt_and_x25519 new file mode 100644 index 0000000000000000000000000000000000000000..c479d3b211d07287e532283a7edf54f5d6118e0e GIT binary patch literal 423 zcmXYrv2L3{0EX4|RP_z2p42fSF>nXQQY$5n2}+2AF^;f09r%DVa9|ENG>s6k$*kA?mClf==L5msPU?aaER-KXOIf40Q`dOZb5ZSaza?5rw3v zIE9SEHlxpO07yy|%Kr~o#gD5dJ?T}TyoaHNv1-9!#_Z8h@0z2i?&DoJAEvjLwQJsV z(%alh&o!?Wv&cTbnZ_X7lIS9oOLt+#`qFTv#*UU+&}j*i3&#;fbT&86kZQZLC&Tki zQ&?<2HvIPdng``}HSY5uIECs6j8@2t_M))r#!3-)wqBa|?K+<~7i@ir^u5|g*Eqyw zmI6glV4|H?gB`9kA5Xa{^l|T~wViiYyMveMERxcRPt3va{T2A|`q%H{S1<3ry}g%T aKfWUm>p%I!;frCs`TqIEr=R}cAMQUBEs!1n literal 0 HcmV?d00001 diff --git a/testdata/testkit/scrypt_no_match b/testdata/testkit/scrypt_no_match new file mode 100644 index 0000000000000000000000000000000000000000..994d64767b0a673eb3ac81207f9e6814598ee6de GIT binary patch literal 270 zcmW;AOHPA87yw|`votPDx*7K(kIqC(qKP)Gv=x!QVMpO-fKs3XQt$%a!9=}458&R! zGZ+)M?mU8t#(cXEstnvh#Q``TaO^u_e9Hm(VGMW)wTfwrP~!ga>9HcwCZ$9n9+9a+ zS_BA1nUm*Pz?~dayy0oW5ONp@khr|giZD%%QqIIuM#34+{}1!7BwlY8@kGyHZGMK^1kH<6c`bq`S+}y017B3kiaNd&WF8tx>T| z$MUMQXG+mE*0vW6r)5M>fSq4dVm|Y2bK#-}efzrq-1$&n>+N%Kc<{4tH=a(v^T)ky L^l-DQzxeOJ>u6hv literal 0 HcmV?d00001 diff --git a/testdata/testkit/scrypt_work_factor_23 b/testdata/testkit/scrypt_work_factor_23 new file mode 100644 index 0000000000000000000000000000000000000000..c37ca072ddccdd3b63d41126a3da80de5d145937 GIT binary patch literal 321 zcmW-Zy-LGS7={t7V8DC$Mxn;E={dIPps1x(p(QD8Yy^ii`SL?@@^g|liFgI#D&B#U zxVw4*E{@KEyNIhnp6z{jA1o8J@;-QI+Q`8%{cy!maQqMdE@r`?dA_D;ceIe literal 0 HcmV?d00001 diff --git a/testdata/stanza_empty_body.test b/testdata/testkit/stanza_empty_body similarity index 100% rename from testdata/stanza_empty_body.test rename to testdata/testkit/stanza_empty_body diff --git a/testdata/stanza_empty_last_line.test b/testdata/testkit/stanza_empty_last_line similarity index 100% rename from testdata/stanza_empty_last_line.test rename to testdata/testkit/stanza_empty_last_line diff --git a/testdata/stanza_missing_body.test b/testdata/testkit/stanza_missing_body similarity index 100% rename from testdata/stanza_missing_body.test rename to testdata/testkit/stanza_missing_body diff --git a/testdata/stanza_missing_final_line.test b/testdata/testkit/stanza_missing_final_line similarity index 100% rename from testdata/stanza_missing_final_line.test rename to testdata/testkit/stanza_missing_final_line diff --git a/testdata/stanza_multiple_short_lines.test b/testdata/testkit/stanza_multiple_short_lines similarity index 100% rename from testdata/stanza_multiple_short_lines.test rename to testdata/testkit/stanza_multiple_short_lines diff --git a/testdata/stream_empty_payload.test b/testdata/testkit/stream_empty_payload similarity index 100% rename from testdata/stream_empty_payload.test rename to testdata/testkit/stream_empty_payload diff --git a/testdata/stream_last_chunk_empty.test b/testdata/testkit/stream_last_chunk_empty similarity index 99% rename from testdata/stream_last_chunk_empty.test rename to testdata/testkit/stream_last_chunk_empty index 8e03661489cab9ffc98cc454dae97167ed91183f..0795d14259fc1c0cb6ebe24861a2be3c4111c87a 100644 GIT binary patch delta 37 scmey<%(APQMLe~lAT_zfN}(XJGABPVMIkLQGpDpDwJ~yQB;#U602ho7J^%m! delta 103 zcmV~$yA8rn3CZdQ)3Q^AxGhG#4ce7Usf8t8k@ipj9GUka>x67FTedkg~c!1<2Dre1`7b F{Q(CfAZh>r diff --git a/testdata/stream_last_chunk_full.test b/testdata/testkit/stream_last_chunk_full similarity index 100% rename from testdata/stream_last_chunk_full.test rename to testdata/testkit/stream_last_chunk_full diff --git a/testdata/testkit/valid_characters b/testdata/testkit/valid_characters new file mode 100644 index 0000000000000000000000000000000000000000..0c88a6e0c043d80d2a47b2f97d3661a13e84f0af GIT binary patch literal 532 zcmWlU%Z`&!06_OF+_*Q_=co+R3*5_vs-qpabZqI9LSbfn02f+jI+SVYgYmKP3tajO zu1(w+x4P1e-(id!V@!-SXM2*96R-0)Dym?h)2 zCIo8%3p7XqHB=Q8YlOwB7(rDHL{)-{6rm6+l9Vth2)QJk#NZ?@s{m^Vqi92di3G8X zF_I8NB9@SbVuZPr#aWRS8?{!af=%^49SBY83!>K=4t1zlzDz0Z`vb3~wM?saAURlR zG#avE!A8QSu`v2BAsSC)7hx96ggoRT)uMk+VvY- z;O4E{{I;-D*}O_J!U_SZR=sog-tK+ypth$Q)U1R3hmEGyYIi`l*S80bI|QD8aCr3S z@e}Yg2qP9JBQQ>nPbR0?6y#^Kd9hfoz`8tt_WZ?5?tjgbFcvj1ps5MVjlqZcGCK3x zrS3Lzi*y#NE^}91i!^&QG>wiParBhxH5xVBd{%MinjH>Pm)~E&8Bf(dAqE@zB~#^W zMI25L1mH1yKGMx*QFiy%4h&|DrxV9_l1{F8y}}ru8+Fsst?+oteg7JM`ttgnywx6m d`}zB#_1-%C`|IP|{^uVbF1*>k^h*4b`~##6rON;S literal 0 HcmV?d00001 diff --git a/testdata/x25519.test b/testdata/testkit/x25519 similarity index 100% rename from testdata/x25519.test rename to testdata/testkit/x25519 diff --git a/testdata/testkit/x25519_multiple_recipients b/testdata/testkit/x25519_multiple_recipients new file mode 100644 index 0000000000000000000000000000000000000000..27c772c2c779515a47a5c3c2febce76744af4389 GIT binary patch literal 520 zcmYk#yONVo0D$41#=^!<`W@tOaxRc@oFM@=o4_Un!Xhr0O7M0lHy!7qX{3r>_6L>^WuOf<7$E?-4s!-{FrXA0 zEN2FwOwV+Jgh6wmYaHl0({u<3%5qHMSA6E&}GC9ua!J5*+Ns%VK9$74X;bYRV89U@7r5Q->yeW}{*p?r0y3-zQ)${RU>7;A>i?%Shzvg}=S zTf-6USM&A=A51^7g3X|z6lc@1g$}Dk3u(8K;zdxD11uw08 zJ@H+CdpsBa9l&u+J7Q+;xqB=7y0SChWmJu(t> x;nCw7;rVC>q~G6P{CI}Lk?~3X`tJS5+2O;_hi`A^>94<^U;jBMFTaeQ{{u_VqJsbc literal 0 HcmV?d00001 diff --git a/testdata/no_match.test b/testdata/testkit/x25519_no_match similarity index 100% rename from testdata/no_match.test rename to testdata/testkit/x25519_no_match diff --git a/testkit_test.go b/testkit_test.go index cfc1233..578efcf 100644 --- a/testkit_test.go +++ b/testkit_test.go @@ -27,19 +27,20 @@ func TestMain(m *testing.M) { flag.Parse() if *genFlag { log.SetFlags(0) - tests, err := filepath.Glob("testdata/*.test") + tests, err := filepath.Glob("testdata/testkit/*") if err != nil { log.Fatal(err) } for _, test := range tests { os.Remove(test) } - generators, err := filepath.Glob("testdata/*.go") + generators, err := filepath.Glob("tests/*.go") if err != nil { log.Fatal(err) } for _, generator := range generators { - vector := strings.TrimSuffix(generator, ".go") + ".test" + vector := strings.TrimSuffix(generator, ".go") + vector = "testdata/testkit/" + strings.TrimPrefix(vector, "tests/") log.Printf("%s -> %s\n", generator, vector) out, err := exec.Command("go", "run", generator).Output() if err != nil { @@ -56,7 +57,7 @@ func TestMain(m *testing.M) { } func TestVectors(t *testing.T) { - tests, err := filepath.Glob("testdata/*.test") + tests, err := filepath.Glob("testdata/testkit/*") if err != nil { log.Fatal(err) } @@ -65,8 +66,7 @@ func TestVectors(t *testing.T) { if err != nil { t.Fatal(err) } - name := strings.TrimPrefix(test, "testdata/") - name = strings.TrimSuffix(name, ".test") + name := strings.TrimPrefix(test, "testdata/testkit/") t.Run(name, func(t *testing.T) { testVector(t, contents) }) @@ -114,6 +114,12 @@ func testVector(t *testing.T, test []byte) { t.Fatal(err) } identities = append(identities, i) + case "passphrase": + i, err := age.NewScryptIdentity(value) + if err != nil { + t.Fatal(err) + } + identities = append(identities, i) case "file key": // Ignored. case "comment": diff --git a/testdata/bad_hmac.go b/tests/bad_hmac.go similarity index 100% rename from testdata/bad_hmac.go rename to tests/bad_hmac.go diff --git a/testdata/long_file_key.go b/tests/long_file_key.go similarity index 100% rename from testdata/long_file_key.go rename to tests/long_file_key.go diff --git a/tests/long_file_key_scrypt.go b/tests/long_file_key_scrypt.go new file mode 100644 index 0000000..1ba3260 --- /dev/null +++ b/tests/long_file_key_scrypt.go @@ -0,0 +1,21 @@ +// Copyright 2022 The age Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build ignore + +package main + +import "filippo.io/age/internal/testkit" + +func main() { + f := testkit.NewTestFile() + f.FileKey([]byte("A LONGER YELLOW SUBMARINE")) + f.VersionLine("v1") + f.Scrypt("password", 10) + f.HMAC() + f.Payload("age") + f.ExpectHeaderFailure() + f.Comment("the file key must be checked to be 16 bytes before decrypting it") + f.Generate() +} diff --git a/tests/scrypt.go b/tests/scrypt.go new file mode 100644 index 0000000..53f540f --- /dev/null +++ b/tests/scrypt.go @@ -0,0 +1,18 @@ +// Copyright 2022 The age Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build ignore + +package main + +import "filippo.io/age/internal/testkit" + +func main() { + f := testkit.NewTestFile() + f.VersionLine("v1") + f.Scrypt("password", 10) + f.HMAC() + f.Payload("age") + f.Generate() +} diff --git a/tests/scrypt_and_x25519.go b/tests/scrypt_and_x25519.go new file mode 100644 index 0000000..03704d0 --- /dev/null +++ b/tests/scrypt_and_x25519.go @@ -0,0 +1,21 @@ +// Copyright 2022 The age Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build ignore + +package main + +import "filippo.io/age/internal/testkit" + +func main() { + f := testkit.NewTestFile() + f.VersionLine("v1") + f.X25519NoRecordIdentity(testkit.TestX25519Identity) + f.Scrypt("password", 10) + f.HMAC() + f.Payload("age") + f.ExpectHeaderFailure() + f.Comment("scrypt stanzas must be alone in the header") + f.Generate() +} diff --git a/tests/scrypt_no_match.go b/tests/scrypt_no_match.go new file mode 100644 index 0000000..a90f53f --- /dev/null +++ b/tests/scrypt_no_match.go @@ -0,0 +1,20 @@ +// Copyright 2022 The age Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build ignore + +package main + +import "filippo.io/age/internal/testkit" + +func main() { + f := testkit.NewTestFile() + f.VersionLine("v1") + f.ScryptRecordPassphrase("wrong") + f.ScryptNoRecordPassphrase("password", 10) + f.HMAC() + f.Payload("age") + f.ExpectHeaderFailure() + f.Generate() +} diff --git a/tests/scrypt_work_factor_23.go b/tests/scrypt_work_factor_23.go new file mode 100644 index 0000000..7586195 --- /dev/null +++ b/tests/scrypt_work_factor_23.go @@ -0,0 +1,23 @@ +// Copyright 2022 The age Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build ignore + +package main + +import "filippo.io/age/internal/testkit" + +func main() { + f := testkit.NewTestFile() + f.VersionLine("v1") + // Hardcoded because it would be too slow to regenerate every time. + // f.Scrypt("password", 23) + f.ArgsLine("scrypt", "rF0/NwblUHHTpgQgRpe5CQ", "23") + f.TextLine("qW9eVsT0NVb/Vswtw8kPIxUnaYmm9Px1dYmq2+4+qZA") + f.HMAC() + f.Payload("age") + f.ExpectHeaderFailure() + f.Comment("work factor is very high, would take a long time to compute") + f.Generate() +} diff --git a/testdata/stanza_empty_body.go b/tests/stanza_empty_body.go similarity index 100% rename from testdata/stanza_empty_body.go rename to tests/stanza_empty_body.go diff --git a/testdata/stanza_empty_last_line.go b/tests/stanza_empty_last_line.go similarity index 100% rename from testdata/stanza_empty_last_line.go rename to tests/stanza_empty_last_line.go diff --git a/testdata/stanza_missing_body.go b/tests/stanza_missing_body.go similarity index 100% rename from testdata/stanza_missing_body.go rename to tests/stanza_missing_body.go diff --git a/testdata/stanza_missing_final_line.go b/tests/stanza_missing_final_line.go similarity index 100% rename from testdata/stanza_missing_final_line.go rename to tests/stanza_missing_final_line.go diff --git a/testdata/stanza_multiple_short_lines.go b/tests/stanza_multiple_short_lines.go similarity index 100% rename from testdata/stanza_multiple_short_lines.go rename to tests/stanza_multiple_short_lines.go diff --git a/testdata/stream_empty_payload.go b/tests/stream_empty_payload.go similarity index 100% rename from testdata/stream_empty_payload.go rename to tests/stream_empty_payload.go diff --git a/testdata/stream_last_chunk_empty.go b/tests/stream_last_chunk_empty.go similarity index 100% rename from testdata/stream_last_chunk_empty.go rename to tests/stream_last_chunk_empty.go diff --git a/testdata/stream_last_chunk_full.go b/tests/stream_last_chunk_full.go similarity index 100% rename from testdata/stream_last_chunk_full.go rename to tests/stream_last_chunk_full.go diff --git a/tests/valid_characters.go b/tests/valid_characters.go new file mode 100644 index 0000000..b617d69 --- /dev/null +++ b/tests/valid_characters.go @@ -0,0 +1,21 @@ +// Copyright 2022 The age Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build ignore + +package main + +import "filippo.io/age/internal/testkit" + +func main() { + f := testkit.NewTestFile() + f.VersionLine("v1") + f.ArgsLine("!\"#$%&'", "()*+,-./", "01234567", "89:;<=>?", "@ABCDEFG", + "HIJKLMNO", "PQRSTUVW", "XYZ[\\]^_", "`abcdefg", "hijklmno", "pqrstuvw", "xyz{|}~") + f.Body([]byte("")) + f.X25519(testkit.TestX25519Recipient) + f.HMAC() + f.Payload("age") + f.Generate() +} diff --git a/testdata/x25519.go b/tests/x25519.go similarity index 100% rename from testdata/x25519.go rename to tests/x25519.go diff --git a/tests/x25519_multiple_recipients.go b/tests/x25519_multiple_recipients.go new file mode 100644 index 0000000..983e0c6 --- /dev/null +++ b/tests/x25519_multiple_recipients.go @@ -0,0 +1,19 @@ +// Copyright 2022 The age Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build ignore + +package main + +import "filippo.io/age/internal/testkit" + +func main() { + f := testkit.NewTestFile() + f.VersionLine("v1") + f.X25519NoRecordIdentity(f.Rand(32)) + f.X25519(testkit.TestX25519Recipient) + f.HMAC() + f.Payload("age") + f.Generate() +} diff --git a/testdata/no_match.go b/tests/x25519_no_match.go similarity index 100% rename from testdata/no_match.go rename to tests/x25519_no_match.go