| 142 | } |
| 143 | |
| 144 | func TestServersRequestOwnKeys(t *testing.T) { |
| 145 | // Each server will request its own keys. There's no reason |
| 146 | // for this to fail as each server should know its own keys. |
| 147 | |
| 148 | for name, s := range servers { |
| 149 | req := gomatrixserverlib.PublicKeyLookupRequest{ |
| 150 | ServerName: s.name, |
| 151 | KeyID: serverKeyID, |
| 152 | } |
| 153 | res, err := s.api.FetchKeys( |
| 154 | context.Background(), |
| 155 | map[gomatrixserverlib.PublicKeyLookupRequest]gomatrixserverlib.Timestamp{ |
| 156 | req: gomatrixserverlib.AsTimestamp(time.Now()), |
| 157 | }, |
| 158 | ) |
| 159 | if err != nil { |
| 160 | t.Fatalf("server could not fetch own key: %s", err) |
| 161 | } |
| 162 | if _, ok := res[req]; !ok { |
| 163 | t.Fatalf("server didn't return its own key in the results") |
| 164 | } |
| 165 | t.Logf("%s's key expires at %s\n", name, res[req].ValidUntilTS.Time()) |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | func TestRenewalBehaviour(t *testing.T) { |
| 170 | // Server A will request Server C's key but their validity period |