-
Notifications
You must be signed in to change notification settings - Fork 0
/
transform_post_query_test.go
47 lines (37 loc) · 1.26 KB
/
transform_post_query_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestTransformPostQuery_Empty(t *testing.T) {
body := []byte("")
redirect := ""
expected := []byte("")
result, err := transformPostQuery(body, redirect)
assert.NoError(t, err)
assert.Equal(t, (expected), (result))
}
func TestTransformPostQuery_EmptyRedirect(t *testing.T) {
body := []byte("redirect_uri=https%3A%2F%2Fexample.com%2Fabc%3Fdef%3Dghi")
redirect := ""
expected := []byte("redirect_uri=https%3A%2F%2Fexample.com%2Fabc%3Fdef%3Dghi")
result, err := transformPostQuery(body, redirect)
assert.NoError(t, err)
assert.Equal(t, (expected), (result))
}
func TestTransformPostQuery_Valid(t *testing.T) {
body := []byte("redirect_uri=https%3A%2F%2Fexample.com%2Fabc%3Fdef%3Dghi")
redirect := "example2.com"
expected := []byte("redirect_uri=https%3A%2F%2Fexample2.com%2Fabc%3Fdef%3Dghi")
result, err := transformPostQuery(body, redirect)
assert.NoError(t, err)
assert.Equal(t, (expected), (result))
}
func TestTransformPostQuery_Invalid(t *testing.T) {
body := []byte("redirect_uri=invalid-uri")
redirect := "example2.com"
expected := []byte("redirect_uri=invalid-uri")
result, err := transformPostQuery(body, redirect)
assert.NoError(t, err)
assert.Equal(t, (expected), (result))
}