package main

import (
	"github.com/stretchr/testify/assert"
	"net/http"
	"net/http/httptest"
	"strings"
	"testing"
)

// func TestAds(t *testing.T) {
// 	router := setupRouter()
//
// 	w := httptest.NewRecorder()
// 	req, _ := http.NewRequest("POST", "/ads?req_source=mh&network_type=9&imei=867252039444772&idfa=&ip=182.37.81.64&ua=Mozilla%2F5.0+%28Linux%3B+Android+8.1.0%3B+MI+8+Build%2FOPM1.171019.026%3B+wv%29+AppleWebKit%2F537.36+%28KHTML%2C+like+Gecko%29+Version%2F4.0+Chrome%2F68.0.3440.91+Mobile+Safari%2F537.36&model=MI+8&brand=Xiaomi&android_id=867252039444772&platform=1", nil)
// 	router.ServeHTTP(w, req)
//
// 	assert.Equal(t, 200, w.Code)
// 	assert.Equal(t, "pong", w.Body.String())
// }

func TestDecrypt(t *testing.T) {
	router := setupRouter()

	w := httptest.NewRecorder()
	r := strings.NewReader("ads_content=a827e6443149663e6d934392fffe24211c7895c5de901c79d0728f903c3aba6943df34363ebfe388dbb70bb824bd10dbed8504e66ed20070d7d5865ee17bd3caf7161039a7b0db08995ff9f9adcbfcd71b688a3c63d5f2ba88b737c4d1c5b016a5328a7df15b494d0c8afd34fd2798226ed9e1c8b2c6203b8ec3440f9df573a5fb093d4f5bf4130e99c9c55fe6cee5fbec2eeaf1d8315919ed1ff0d0490f4ff88d87d6a8094bfa18aa35f0d7349a633e1ea65297e9817b81cf35628fb4695e78bcd58eeb4ed645e2f7188c662727a98d0b587378bc973c92f8c566ea644e0cfe66e41ba11b0dfe8075b5ff8ce82f9e2d81ee7d99eefe9a899c790f8fe21eb30bca124429ae41a9dc95166e2a84763634de63ba01e53ce0f0788112558d16c08c40d324b910284f633d66d55cbea2dcbdc16f16c8f08f621d0a1b665550d3fb282b5c0b9bc54bd1c3b8a7f900a92acc560c452af6b8f9e13f1fd4fbcdc42e2ca110b471d708e63fda33f306c95acb96b15ea75fafbbeba979ddf7ccf91f777ed5bb810f493338ed4436c3ccebcb993b4cd8dd46610f29ec8d9ba6390f0a4f2821&new_ads_flag=1")
	req, _ := http.NewRequest("POST", "/ads", r)
	router.ServeHTTP(w, req)

	assert.Equal(t, 200, w.Code)
	assert.Equal(t, "pong", w.Body.String())
}
