Copy of github.com/askrobots/network-computer (MIT): a desk you reach from anything. The original lives on GitHub.

2 downloads

Download zip
Clone
Clone with git
git clone https://gitstable.com/git/demo/network-computer.git
HTTPS
https://gitstable.com/git/demo/network-computer.git
SSH
ssh://git@gitstable.com:2222/demo/network-computer.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

GitStable demo README: say this is a copy and where the original is cde82c2 13 hours, 39 minutes ago History
auth_test.go · 1.1 KB · 33 lines
1package main
2
3import (
4 "net/http/httptest"
5 "testing"
6)
7
8func TestWrongPasswordsAreLimitedPerAddress(t *testing.T) {
9 a := newAuthority("nc", "right")
10 r := httptest.NewRequest("POST", "/auth", nil)
11 r.RemoteAddr = "203.0.113.9:4000"
12 for i := 0; i < maxFails; i++ {
13 if ok, limited := a.checkCredsFrom(r, "nc", "wrong"); ok || limited {
14 t.Fatalf("attempt %d: ok=%v limited=%v", i, ok, limited)
15 }
16 }
17 if ok, limited := a.checkCredsFrom(r, "nc", "right"); ok || !limited {
18 t.Fatalf("after %d failures the right password should be refused too: ok=%v limited=%v", maxFails, ok, limited)
19 }
20 other := httptest.NewRequest("POST", "/auth", nil)
21 other.RemoteAddr = "198.51.100.7:5000"
22 if ok, _ := a.checkCredsFrom(other, "nc", "right"); !ok {
23 t.Fatal("another address must not be limited")
24 }
25 local := httptest.NewRequest("POST", "/auth", nil)
26 local.RemoteAddr = "127.0.0.1:6000"
27 for i := 0; i < maxFails+5; i++ {
28 a.checkCredsFrom(local, "nc", "wrong")
29 }
30 if ok, limited := a.checkCredsFrom(local, "nc", "right"); !ok || limited {
31 t.Fatal("the desk itself (loopback) is never limited")
32 }
33}