2024-05-24 10:25:37 +00:00
|
|
|
package e2e
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bufio"
|
|
|
|
"fmt"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"net/http"
|
2024-11-18 07:23:41 +00:00
|
|
|
"gitea.pena/PenaSide/customer/tests/helpers"
|
2024-05-24 10:25:37 +00:00
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestAccountPipe(t *testing.T) {
|
2024-06-08 12:50:59 +00:00
|
|
|
jwtUtil := helpers.InitializeJWT()
|
|
|
|
|
|
|
|
token, tokenErr := jwtUtil.Create("64ebda4387392e122e5d411f")
|
|
|
|
if !assert.NoError(t, tokenErr) {
|
|
|
|
return
|
|
|
|
}
|
2024-06-11 08:57:38 +00:00
|
|
|
fmt.Println(token)
|
|
|
|
url := fmt.Sprintf("http://localhost:8082/account/pipe?Authorization=%s", token)
|
2024-05-24 10:25:37 +00:00
|
|
|
client := &http.Client{
|
|
|
|
Timeout: 100 * time.Second,
|
|
|
|
}
|
|
|
|
|
|
|
|
req, err := http.NewRequest("GET", url, nil)
|
|
|
|
if !assert.NoError(t, err) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
req.Header.Set("Accept", "text/event-stream")
|
|
|
|
|
|
|
|
resp, err := client.Do(req)
|
|
|
|
if !assert.NoError(t, err) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
defer resp.Body.Close()
|
|
|
|
|
|
|
|
assert.Equal(t, http.StatusOK, resp.StatusCode, "Expected status code 200")
|
|
|
|
|
|
|
|
scanner := bufio.NewScanner(resp.Body)
|
|
|
|
for scanner.Scan() {
|
|
|
|
line := scanner.Text()
|
|
|
|
fmt.Println("Received:", line)
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := scanner.Err(); err != nil {
|
|
|
|
t.Fatalf("Error reading response: %v", err)
|
|
|
|
}
|
|
|
|
}
|