| 1 | package signjarscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/ |
| 2 | |
| 3 | import ( |
| 4 | "net/httpscip-go gomod github.com/golang/go/src go1.18 `net/http`/" |
| 5 | "stringsscip-go gomod github.com/golang/go/src go1.18 strings/" |
| 6 | "testingscip-go gomod github.com/golang/go/src go1.18 testing/" |
| 7 | |
| 8 | "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/assert`/" |
| 9 | "github.com/stretchr/testify/requirescip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/require`/" |
| 10 | ) |
| 11 | |
| 12 | func TestParsescip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/TestParse().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 13 | t.Parallelscip-go gomod github.com/golang/go/src go1.18 testing/T#Parallel().() |
| 14 | t.Runscip-go gomod github.com/golang/go/src go1.18 testing/T#Run().("Full", func(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 15 | const manifest = `Manifest-Version: 1.0 |
| 16 | Built-By: nobody |
| 17 | Long-Header-Line: 0123456789abcdef0123456789abcdef0123456789abcdef |
| 18 | 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef |
| 19 | 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef |
| 20 | |
| 21 | Name: foo |
| 22 | Ham: spam |
| 23 | Eggs: bacon |
| 24 | |
| 25 | ` |
| 26 | main := httpscip-go gomod github.com/golang/go/src go1.18 `net/http`/.Headerscip-go gomod github.com/golang/go/src go1.18 `net/http`/Header#{ |
| 27 | "Manifest-Version": []string{"1.0"}, |
| 28 | "Built-By": []string{"nobody"}, |
| 29 | "Long-Header-Line": []string{ |
| 30 | "0123456789abcdef0123456789abcdef" + |
| 31 | "0123456789abcdef0123456789abcdef0123456789abcdef" + |
| 32 | "0123456789abcdef0123456789abcdef0123456789abcdef" + |
| 33 | "0123456789abcdef0123456789abcdef0123456789abcdef"}, |
| 34 | } |
| 35 | file := httpscip-go gomod github.com/golang/go/src go1.18 `net/http`/.Headerscip-go gomod github.com/golang/go/src go1.18 `net/http`/Header#{ |
| 36 | "Name": []string{"foo"}, |
| 37 | "Ham": []string{"spam"}, |
| 38 | "Eggs": []string{"bacon"}, |
| 39 | } |
| 40 | expected := &FilesMapscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/FilesMap#{ |
| 41 | Mainscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/FilesMap#Main.: main, |
| 42 | Filesscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/FilesMap#Files.: map[string]httpscip-go gomod github.com/golang/go/src go1.18 `net/http`/.Headerscip-go gomod github.com/golang/go/src go1.18 `net/http`/Header#{"foo": file}, |
| 43 | Orderscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/FilesMap#Order.: []string{"foo"}, |
| 44 | } |
| 45 | parsed, err := ParseManifestscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/ParseManifest().([]byte(manifest)) |
| 46 | requirescip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 47 | assertscip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/assert`/Equal().(t, expected, parsed) |
| 48 | crlfManifest := []byte(stringsscip-go gomod github.com/golang/go/src go1.18 strings/.ReplaceAllscip-go gomod github.com/golang/go/src go1.18 strings/ReplaceAll().(manifest, "\n", "\r\n")) |
| 49 | parsed, err = ParseManifestscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/ParseManifest().(crlfManifest) |
| 50 | requirescip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 51 | assertscip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/assert`/Equal().(t, expected, parsed) |
| 52 | }) |
| 53 | t.Runscip-go gomod github.com/golang/go/src go1.18 testing/T#Run().("TruncatedMain", func(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 54 | const manifest = "Manifest-Version: 1.0\n" |
| 55 | expected := &FilesMapscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/FilesMap#{ |
| 56 | Mainscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/FilesMap#Main.: httpscip-go gomod github.com/golang/go/src go1.18 `net/http`/.Headerscip-go gomod github.com/golang/go/src go1.18 `net/http`/Header#{ |
| 57 | "Manifest-Version": []string{"1.0"}, |
| 58 | }, |
| 59 | Orderscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/FilesMap#Order.: []string{}, |
| 60 | Filesscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/FilesMap#Files.: map[string]httpscip-go gomod github.com/golang/go/src go1.18 `net/http`/.Headerscip-go gomod github.com/golang/go/src go1.18 `net/http`/Header#{}, |
| 61 | } |
| 62 | _, err := ParseManifestscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/ParseManifest().([]byte(manifest)) |
| 63 | requirescip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/require`/.ErrorIsscip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/require`/ErrorIs().(t, err, ErrManifestLineEndingsscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/ErrManifestLineEndings.) |
| 64 | parsed, malformed, err := parseManifestscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/parseManifest().([]byte(manifest)) |
| 65 | requirescip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 66 | assertscip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/assert`/True().(t, malformed) |
| 67 | assertscip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/assert`/Equal().(t, expected, parsed) |
| 68 | }) |
| 69 | t.Runscip-go gomod github.com/golang/go/src go1.18 testing/T#Run().("TruncatedFile", func(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 70 | const manifest = "Manifest-Version: 1.0\n\nName: foo\n" |
| 71 | file := httpscip-go gomod github.com/golang/go/src go1.18 `net/http`/.Headerscip-go gomod github.com/golang/go/src go1.18 `net/http`/Header#{ |
| 72 | "Name": []string{"foo"}, |
| 73 | } |
| 74 | expected := &FilesMapscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/FilesMap#{ |
| 75 | Mainscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/FilesMap#Main.: httpscip-go gomod github.com/golang/go/src go1.18 `net/http`/.Headerscip-go gomod github.com/golang/go/src go1.18 `net/http`/Header#{ |
| 76 | "Manifest-Version": []string{"1.0"}, |
| 77 | }, |
| 78 | Orderscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/FilesMap#Order.: []string{"foo"}, |
| 79 | Filesscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/FilesMap#Files.: map[string]httpscip-go gomod github.com/golang/go/src go1.18 `net/http`/.Headerscip-go gomod github.com/golang/go/src go1.18 `net/http`/Header#{"foo": file}, |
| 80 | } |
| 81 | _, err := ParseManifestscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/ParseManifest().([]byte(manifest)) |
| 82 | requirescip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/require`/.ErrorIsscip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/require`/ErrorIs().(t, err, ErrManifestLineEndingsscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/ErrManifestLineEndings.) |
| 83 | parsed, malformed, err := parseManifestscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/parseManifest().([]byte(manifest)) |
| 84 | requirescip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 85 | assertscip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/assert`/True().(t, malformed) |
| 86 | assertscip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/assert`/Equal().(t, expected, parsed) |
| 87 | }) |
| 88 | t.Runscip-go gomod github.com/golang/go/src go1.18 testing/T#Run().("TrailingWhitespace", func(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 89 | const manifest = "Manifest-Version: 1.0\n\nName: foo\n\n\n" |
| 90 | file := httpscip-go gomod github.com/golang/go/src go1.18 `net/http`/.Headerscip-go gomod github.com/golang/go/src go1.18 `net/http`/Header#{ |
| 91 | "Name": []string{"foo"}, |
| 92 | } |
| 93 | expected := &FilesMapscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/FilesMap#{ |
| 94 | Mainscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/FilesMap#Main.: httpscip-go gomod github.com/golang/go/src go1.18 `net/http`/.Headerscip-go gomod github.com/golang/go/src go1.18 `net/http`/Header#{ |
| 95 | "Manifest-Version": []string{"1.0"}, |
| 96 | }, |
| 97 | Orderscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/FilesMap#Order.: []string{"foo"}, |
| 98 | Filesscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/FilesMap#Files.: map[string]httpscip-go gomod github.com/golang/go/src go1.18 `net/http`/.Headerscip-go gomod github.com/golang/go/src go1.18 `net/http`/Header#{"foo": file}, |
| 99 | } |
| 100 | _, err := ParseManifestscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/ParseManifest().([]byte(manifest)) |
| 101 | requirescip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/require`/.ErrorIsscip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/require`/ErrorIs().(t, err, ErrManifestLineEndingsscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/ErrManifestLineEndings.) |
| 102 | parsed, malformed, err := parseManifestscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/parseManifest().([]byte(manifest)) |
| 103 | requirescip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 104 | assertscip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/assert`/True().(t, malformed) |
| 105 | assertscip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/assert`/Equal().(t, expected, parsed) |
| 106 | }) |
| 107 | t.Runscip-go gomod github.com/golang/go/src go1.18 testing/T#Run().("InvalidNoName", func(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 108 | const manifest = "Manifest-Version: 1.0\n\nFoo: bar\n\n" |
| 109 | _, err := ParseManifestscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/ParseManifest().([]byte(manifest)) |
| 110 | requirescip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/require`/.Errorscip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/require`/Error().(t, err) |
| 111 | }) |
| 112 | } |
| 113 | |
| 114 | func TestDumpscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/TestDump().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 115 | manifest := &FilesMapscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/FilesMap#{ |
| 116 | Mainscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/FilesMap#Main.: httpscip-go gomod github.com/golang/go/src go1.18 `net/http`/.Headerscip-go gomod github.com/golang/go/src go1.18 `net/http`/Header#{ |
| 117 | "Manifest-Version": []string{"1.0"}, |
| 118 | "D": []string{"D"}, |
| 119 | "C": []string{"C"}, |
| 120 | "B": []string{"B"}, |
| 121 | "A": []string{"A"}, |
| 122 | "Long-Header": []string{stringsscip-go gomod github.com/golang/go/src go1.18 strings/.Repeatscip-go gomod github.com/golang/go/src go1.18 strings/Repeat().("0123456789abcdef", 10)}, |
| 123 | }, |
| 124 | Filesscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/FilesMap#Files.: map[string]httpscip-go gomod github.com/golang/go/src go1.18 `net/http`/.Headerscip-go gomod github.com/golang/go/src go1.18 `net/http`/Header#{ |
| 125 | "foo": {"Name": []string{"foo"}, "Foo": []string{"bar"}}, |
| 126 | "bar": {"Name": []string{"bar"}, "Foo": []string{"bar"}}, |
| 127 | }, |
| 128 | Orderscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/FilesMap#Order.: []string{"bar", "foo"}, |
| 129 | } |
| 130 | result := string(manifest.Dumpscip-go gomod github.com/sassoftware/relic/v7 . `github.com/sassoftware/relic/v7/lib/signjar`/FilesMap#Dump().()) |
| 131 | expected := `Manifest-Version: 1.0 |
| 132 | A: A |
| 133 | B: B |
| 134 | C: C |
| 135 | D: D |
| 136 | Long-Header: 0123456789abcdef0123456789abcdef0123456789abcdef012345678 |
| 137 | 9abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcd |
| 138 | ef0123456789abcdef0123456789abcdef |
| 139 | |
| 140 | Name: bar |
| 141 | Foo: bar |
| 142 | |
| 143 | Name: foo |
| 144 | Foo: bar |
| 145 | |
| 146 | ` |
| 147 | expected = stringsscip-go gomod github.com/golang/go/src go1.18 strings/.ReplaceAllscip-go gomod github.com/golang/go/src go1.18 strings/ReplaceAll().(expected, "\n", "\r\n") |
| 148 | assertscip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.2 `github.com/stretchr/testify/assert`/Equal().(t, expected, result) |
| 149 | } |