Commit 4581f23b authored by vicotor's avatar vicotor

add api to add account

parent 4e94b8be
...@@ -80,3 +80,12 @@ func SetNotAvailable(username string, errStr string) error { ...@@ -80,3 +80,12 @@ func SetNotAvailable(username string, errStr string) error {
return err return err
} }
func AddAccount(acc Account) error {
//fmt.Printf("add account %v\n", acc)
res, _, err := client.From("accounts").Insert(acc, true, "", "representation", "").Execute()
_ = res
return err
}
...@@ -163,6 +163,33 @@ func TestRateLimiter(t *testing.T) { ...@@ -163,6 +163,33 @@ func TestRateLimiter(t *testing.T) {
} }
} }
func TestAddAccount(t *testing.T) {
acclist := `ADeirdre20860----PtmcQvWd1DoD----tlugmeqmyt@rambler.ru----1589408cnVMmCa----P7G5GRG7ULCYKBMY----808f3b93ac4f9b0ac5085a3b1ba608e1c1a8e675
EulaSusann56500----SuIZROXhN14D----szahcqejrt@rambler.ru----9911065aAPM8ga----XDC6WMJEH4ILTTXN----f44e136089679d62247f353570be9cc78c60ff6b
MShondra82485----B7P38LYzz----mvwadpmfxr@rambler.ru----5973556MwG4gqa----I6XQJHQMUUL5MDXX----a43cbb2fd4a891e0513169131fe7dc7a0bb54f1f
KylieBritt10079----up1kj10rgjkry----xttuuxbtdc@rambler.ru----9507993gP7QJCa----GDZ6QWDQ5Q2KDOE5----330f127059d8a686cc0bc82e12aac5380fce9b03
StevieJ95145----9XqzE8JBSd----kkkfqtgkym@rambler.ru----5141799R36rxaa----ZFRHKNVV3TAU6GJ6----55bbfe00bfc34c4e9e7cc6d46eef0cd79ff31284`
accs := strings.Split(acclist, "\n")
for _, v := range accs {
info := strings.Split(v, "----")
if len(info) != 6 {
t.Errorf("invalid account info %s", v)
} else {
record := Account{
Username: info[0],
Password: info[1],
Email: info[2],
F2A: info[4],
Available: true,
}
if err := AddAccount(record); err != nil {
t.Error(err)
} else {
t.Logf("add account %s success", record.Username)
}
}
}
}
func TestLogin(t *testing.T) { func TestLogin(t *testing.T) {
//userCookies := make(map[string][]*http.Cookie) //userCookies := make(map[string][]*http.Cookie)
info := []struct { info := []struct {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment