Pull request: * all: move internal Go packages to internal/
Merge in DNS/adguard-home from 2234-move-to-internal to master Squashed commit of the following: commit d26a288cabeac86f9483fab307677b1027c78524 Author: Eugene Burkov <e.burkov@adguard.com> Date: Fri Oct 30 12:44:18 2020 +0300 * all: move internal Go packages to internal/ Closes #2234.
This commit is contained in:
43
internal/home/auth_glinet_test.go
Normal file
43
internal/home/auth_glinet_test.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package home
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestAuthGL(t *testing.T) {
|
||||
dir := prepareTestDir()
|
||||
defer func() { _ = os.RemoveAll(dir) }()
|
||||
|
||||
GLMode = true
|
||||
glFilePrefix = dir + "/gl_token_"
|
||||
|
||||
tval := uint32(1)
|
||||
data := make([]byte, 4)
|
||||
if archIsLittleEndian() {
|
||||
binary.LittleEndian.PutUint32(data, tval)
|
||||
} else {
|
||||
binary.BigEndian.PutUint32(data, tval)
|
||||
}
|
||||
assert.Nil(t, ioutil.WriteFile(glFilePrefix+"test", data, 0644))
|
||||
assert.False(t, glCheckToken("test"))
|
||||
|
||||
tval = uint32(time.Now().UTC().Unix() + 60)
|
||||
data = make([]byte, 4)
|
||||
if archIsLittleEndian() {
|
||||
binary.LittleEndian.PutUint32(data, tval)
|
||||
} else {
|
||||
binary.BigEndian.PutUint32(data, tval)
|
||||
}
|
||||
assert.Nil(t, ioutil.WriteFile(glFilePrefix+"test", data, 0644))
|
||||
r, _ := http.NewRequest("GET", "http://localhost/", nil)
|
||||
r.AddCookie(&http.Cookie{Name: glCookieName, Value: "test"})
|
||||
assert.True(t, glProcessCookie(r))
|
||||
GLMode = false
|
||||
}
|
||||
Reference in New Issue
Block a user