-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2:支持统一时区设置(docker部署需要用到) Changes to be committed: modified: README.md modified: apiserver.go new file: apiserver_test.go modified: config.go modified: config_test.go modified: const.go modified: func.go modified: main.go modified: model.go modified: sms.go new file: zoneinfo.zip
- Loading branch information
Showing
12 changed files
with
255 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o smscode . | ||
FROM scratch | ||
ADD smscode / | ||
COPY etc/* /etc/ | ||
COPY conf/* /conf/ | ||
CMD ["/smscode"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
package main | ||
|
||
import ( | ||
"io/ioutil" | ||
"net/http" | ||
"net/url" | ||
"testing" | ||
) | ||
|
||
func TestApiserver(t *testing.T) { | ||
|
||
if e := recover(); e != nil { | ||
t.Error(e) | ||
} | ||
|
||
config.Bind = "0.0.0.0:8080" | ||
go func() { | ||
Apiserver() | ||
}() | ||
|
||
t.Run("Send", testsend) | ||
t.Run("Checkcode", testcheckcode) | ||
t.Run("Setuid", testsetuid) | ||
t.Run("Deluid", testdeluid) | ||
t.Run("Info", testinfo) | ||
} | ||
|
||
func testsend(t *testing.T) { | ||
apiurl := "http://" + config.Bind | ||
var data = url.Values{} | ||
data.Set("mobile", "13575566313") | ||
data.Set("service", "register") | ||
res, err := http.DefaultClient.PostForm(apiurl+"/send", data) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
defer res.Body.Close() | ||
cont, err := ioutil.ReadAll(res.Body) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
t.Log(string(cont)) | ||
} | ||
|
||
func testcheckcode(t *testing.T) { | ||
apiurl := "http://" + config.Bind | ||
var data = url.Values{} | ||
data.Set("mobile", "13575566313") | ||
data.Set("service", "register") | ||
data.Set("code", "333333") | ||
res, err := http.DefaultClient.PostForm(apiurl+"/checkcode", data) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
defer res.Body.Close() | ||
cont, err := ioutil.ReadAll(res.Body) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
t.Log(string(cont)) | ||
} | ||
|
||
func testsetuid(t *testing.T) { | ||
apiurl := "http://" + config.Bind | ||
var data = url.Values{} | ||
data.Set("mobile", "13575566313") | ||
data.Set("service", "register") | ||
data.Set("uid", "1") | ||
res, err := http.DefaultClient.PostForm(apiurl+"/setuid", data) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
defer res.Body.Close() | ||
cont, err := ioutil.ReadAll(res.Body) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
t.Log(string(cont)) | ||
} | ||
|
||
func testdeluid(t *testing.T) { | ||
apiurl := "http://" + config.Bind | ||
var data = url.Values{} | ||
data.Set("mobile", "13575566313") | ||
data.Set("service", "register") | ||
data.Set("uid", "1") | ||
res, err := http.DefaultClient.PostForm(apiurl+"/deluid", data) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
defer res.Body.Close() | ||
cont, err := ioutil.ReadAll(res.Body) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
t.Log(string(cont)) | ||
} | ||
|
||
func testinfo(t *testing.T) { | ||
apiurl := "http://" + config.Bind | ||
var data = url.Values{} | ||
data.Set("mobile", "13575566313") | ||
data.Set("service", "register") | ||
res, err := http.DefaultClient.PostForm(apiurl+"/info", data) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
defer res.Body.Close() | ||
cont, err := ioutil.ReadAll(res.Body) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
t.Log(string(cont)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.