mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-17 19:08:25 -07:00
67164f89f3
Merge in DNS/adguard-home from fix-some to master Squashed commit of the following: commit 190e9a88d9c0f2bfc597aa61b41dae8b8686158e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Mar 16 20:50:02 2021 +0300 all: add native endianness, imp Makefile
37 lines
857 B
Go
37 lines
857 B
Go
package home
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"net/http"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/AdguardTeam/AdGuardHome/internal/aghos"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestAuthGL(t *testing.T) {
|
|
dir := prepareTestDir(t)
|
|
|
|
GLMode = true
|
|
t.Cleanup(func() {
|
|
GLMode = false
|
|
})
|
|
glFilePrefix = dir + "/gl_token_"
|
|
|
|
data := make([]byte, 4)
|
|
aghos.NativeEndian.PutUint32(data, 1)
|
|
|
|
require.Nil(t, ioutil.WriteFile(glFilePrefix+"test", data, 0o644))
|
|
assert.False(t, glCheckToken("test"))
|
|
|
|
data = make([]byte, 4)
|
|
aghos.NativeEndian.PutUint32(data, uint32(time.Now().UTC().Unix()+60))
|
|
|
|
require.Nil(t, ioutil.WriteFile(glFilePrefix+"test", data, 0o644))
|
|
r, _ := http.NewRequest(http.MethodGet, "http://localhost/", nil)
|
|
r.AddCookie(&http.Cookie{Name: glCookieName, Value: "test"})
|
|
assert.True(t, glProcessCookie(r))
|
|
}
|