(t *testing.T)
| 53 | } |
| 54 | |
| 55 | func TestBundleTamper(t *testing.T) { |
| 56 | root := GenerateKey() |
| 57 | cfg := CentralCfg{ |
| 58 | Dist: nil, |
| 59 | Routers: make([]RouterCfg, 0), |
| 60 | Clients: []ClientCfg{ |
| 61 | {NodeCfg{ |
| 62 | Id: "blah", |
| 63 | PubKey: NyPublicKey{}, |
| 64 | Prefixes: []PrefixHealthWrapper{ |
| 65 | { |
| 66 | &StaticPrefixHealth{ |
| 67 | Prefix: netip.MustParsePrefix("10.0.0.1/32"), |
| 68 | Metric: 0, |
| 69 | }, |
| 70 | }, |
| 71 | { |
| 72 | &StaticPrefixHealth{ |
| 73 | Prefix: netip.MustParsePrefix("10.0.0.2/32"), |
| 74 | Metric: 0, |
| 75 | }, |
| 76 | }, |
| 77 | { |
| 78 | &StaticPrefixHealth{ |
| 79 | Prefix: netip.MustParsePrefix("10.0.0.3/8"), |
| 80 | Metric: 0, |
| 81 | }, |
| 82 | }, |
| 83 | }, |
| 84 | }}, |
| 85 | }, |
| 86 | Graph: []string{ |
| 87 | "blah, blah", |
| 88 | "a = blah", |
| 89 | "b = a", |
| 90 | "a, b", |
| 91 | }, |
| 92 | Timestamp: 0, |
| 93 | } |
| 94 | txt, err := yaml.Marshal(cfg) |
| 95 | assert.NoError(t, err) |
| 96 | bundle, err := BundleConfig(string(txt), root) |
| 97 | assert.NoError(t, err) |
| 98 | |
| 99 | buf := []byte(bundle) |
| 100 | if buf[0] == 'a' { |
| 101 | buf[0] = 'b' |
| 102 | } else { |
| 103 | buf[0] = 'a' |
| 104 | } |
| 105 | bundle = string(buf) |
| 106 | |
| 107 | _, err = UnbundleConfig(bundle, root.Pubkey()) |
| 108 | assert.ErrorContains(t, err, "message authentication failed") |
| 109 | } |
| 110 | |
| 111 | func TestBundleInvalidSign(t *testing.T) { |
| 112 | root := GenerateKey() |
nothing calls this directly
no test coverage detected