2019-11-25 03:27:59 +07:00
|
|
|
package suites
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
"testing"
|
|
|
|
|
2019-11-30 23:49:52 +07:00
|
|
|
"github.com/stretchr/testify/require"
|
2019-11-25 03:27:59 +07:00
|
|
|
)
|
|
|
|
|
|
|
|
// DuoPolicy a type of policy
|
|
|
|
type DuoPolicy int32
|
|
|
|
|
|
|
|
const (
|
|
|
|
// Deny deny policy
|
|
|
|
Deny DuoPolicy = iota
|
|
|
|
// Allow allow policy
|
|
|
|
Allow DuoPolicy = iota
|
|
|
|
)
|
|
|
|
|
|
|
|
// ConfigureDuo configure duo api to allow or block auth requests
|
|
|
|
func ConfigureDuo(t *testing.T, allowDeny DuoPolicy) {
|
|
|
|
url := fmt.Sprintf("%s/allow", DuoBaseURL)
|
|
|
|
if allowDeny == Deny {
|
|
|
|
url = fmt.Sprintf("%s/deny", DuoBaseURL)
|
|
|
|
}
|
|
|
|
|
|
|
|
req, err := http.NewRequest("POST", url, nil)
|
2019-11-30 23:49:52 +07:00
|
|
|
require.NoError(t, err)
|
2019-11-25 03:27:59 +07:00
|
|
|
|
|
|
|
client := NewHTTPClient()
|
|
|
|
res, err := client.Do(req)
|
2019-11-30 23:49:52 +07:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, 200, res.StatusCode)
|
2019-11-25 03:27:59 +07:00
|
|
|
}
|