Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
10515ce46b |
No files matched your search
@@ -235,10 +235,15 @@ so each answer's policy names a random nonce made for that answer, and the
|
|||||||
browser applies or runs only the blocks that carry it. The pages therefore use
|
browser applies or runs only the blocks that carry it. The pages therefore use
|
||||||
no `style` attributes, which a nonce cannot cover.
|
no `style` attributes, which a nonce cannot cover.
|
||||||
|
|
||||||
An origin AS of 0 (`origin_asn` in a route, `asn` and `origin_asns` in an IP
|
An origin AS of 0 means the route has no known origin. Its AS path ends in an AS
|
||||||
lookup, the key `0` in a prefix's `origins`) means the route has no known
|
set of several members, any of which may have originated it. The 0 appears in
|
||||||
origin: its AS path ends in an AS set of several members, any of which may have
|
these fields:
|
||||||
originated it. The pages show such a route as having no known origin.
|
|
||||||
|
- `origin_asn` in a route
|
||||||
|
- `asn` and `origin_asns` in an IP lookup
|
||||||
|
- the key `0` in a prefix's `origins`
|
||||||
|
|
||||||
|
The pages show such a route as having no known origin.
|
||||||
|
|
||||||
## Blocklists
|
## Blocklists
|
||||||
|
|
||||||
|
|||||||
@@ -1316,6 +1316,9 @@ func TestIPLookupReportsBlocklists(t *testing.T) {
|
|||||||
// jsonNull is how JSON writes a field without a value.
|
// jsonNull is how JSON writes a field without a value.
|
||||||
const jsonNull = "null"
|
const jsonNull = "null"
|
||||||
|
|
||||||
|
// jsonEmptyList is how JSON writes an empty list.
|
||||||
|
const jsonEmptyList = "[]"
|
||||||
|
|
||||||
// resultFields decodes an IP lookup answer and returns each of its results as
|
// resultFields decodes an IP lookup answer and returns each of its results as
|
||||||
// its JSON fields.
|
// its JSON fields.
|
||||||
func resultFields(t *testing.T, answer []byte) []map[string]json.RawMessage {
|
func resultFields(t *testing.T, answer []byte) []map[string]json.RawMessage {
|
||||||
@@ -1451,6 +1454,37 @@ func TestIPLookupResultsHaveTheSameFields(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestIPLookupOfAnAddressWithoutPTRNamesOrStoredNetblock looks up a routed
|
||||||
|
// address that has no PTR names, and whose netblock the database has not
|
||||||
|
// stored. Its ptr is an empty list and its first_seen is null. Before the fix
|
||||||
|
// ptr was left out, and first_seen was 0001-01-01T00:00:00Z
|
||||||
|
// (https://git.eeqj.de/sneak/routewatch/issues/200).
|
||||||
|
func TestIPLookupOfAnAddressWithoutPTRNamesOrStoredNetblock(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
s := newServerWithTestRoutes(t)
|
||||||
|
s.resolver = &fakeResolver{}
|
||||||
|
|
||||||
|
path := "/api/v1/ip/" + addrInTestPrefixV4
|
||||||
|
|
||||||
|
results := resultFields(t, get(t, s, path).Body.Bytes())
|
||||||
|
if len(results) != 1 {
|
||||||
|
t.Fatalf("%s: %d results, want 1", path, len(results))
|
||||||
|
}
|
||||||
|
|
||||||
|
want := map[string]string{
|
||||||
|
"ptr": jsonEmptyList,
|
||||||
|
"first_seen": jsonNull,
|
||||||
|
}
|
||||||
|
|
||||||
|
for name, value := range want {
|
||||||
|
got := string(results[0][name])
|
||||||
|
if got != value {
|
||||||
|
t.Errorf("%s: %s is %s, want %s", path, name, got, value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TestIPLookupAnswersMayBeCached checks the Cache-Control header of the IP
|
// TestIPLookupAnswersMayBeCached checks the Cache-Control header of the IP
|
||||||
// lookup answers. Caches may keep them for the blocklists' shortest interval,
|
// lookup answers. Caches may keep them for the blocklists' shortest interval,
|
||||||
// and only the caller's own browser may keep the answer about the caller's
|
// and only the caller's own browser may keep the answer about the caller's
|
||||||
|
|||||||
Reference in new issue
Block a user