Improves unit tests

This commit is contained in:
Manu Mtz-Almeida
2015-04-08 02:58:35 +02:00
parent 67f8f6bb69
commit ac0ad2fed8
14 changed files with 784 additions and 624 deletions

View File

@ -9,7 +9,6 @@ import (
"encoding/base64"
"errors"
"fmt"
"log"
"sort"
)
@ -61,12 +60,12 @@ func BasicAuth(accounts Accounts) HandlerFunc {
func processAccounts(accounts Accounts) authPairs {
if len(accounts) == 0 {
log.Panic("Empty list of authorized credentials")
panic("Empty list of authorized credentials")
}
pairs := make(authPairs, 0, len(accounts))
for user, password := range accounts {
if len(user) == 0 {
log.Panic("User can not be empty")
panic("User can not be empty")
}
base := user + ":" + password
value := "Basic " + base64.StdEncoding.EncodeToString([]byte(base))