-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_test.go
More file actions
18 lines (16 loc) · 6.72 KB
/
Copy pathmain_test.go
File metadata and controls
18 lines (16 loc) · 6.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package main
import (
"crypto/hmac"
"crypto/sha1"
"fmt"
"io"
"testing"
)
func TestWindows(t *testing.T) {
token := "123456"
x := `{"ref":"refs/heads/master","before":"fa899549d0bb05b1f92596a7aa9e3980ea6acc72","after":"f2305457193c3e6088c8aac5eccc7ab4a7e58f01","repository":{"id":252112649,"node_id":"MDEwOlJlcG9zaXRvcnkyNTIxMTI2NDk=","name":"scs","full_name":"hyahm/scs","private":false,"owner":{"name":"hyahm","email":"cander_liubiao@126.com","login":"hyahm","id":22030094,"node_id":"MDQ6VXNlcjIyMDMwMDk0","avatar_url":"https://avatars3.githubusercontent.com/u/22030094?v=4","gravatar_id":"","url":"https://api.github.com/users/hyahm","html_url":"https://github.com/hyahm","followers_url":"https://api.github.com/users/hyahm/followers","following_url":"https://api.github.com/users/hyahm/following{/other_user}","gists_url":"https://api.github.com/users/hyahm/gists{/gist_id}","starred_url":"https://api.github.com/users/hyahm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hyahm/subscriptions","organizations_url":"https://api.github.com/users/hyahm/orgs","repos_url":"https://api.github.com/users/hyahm/repos","events_url":"https://api.github.com/users/hyahm/events{/privacy}","received_events_url":"https://api.github.com/users/hyahm/received_events","type":"User","site_admin":false},"html_url":"https://github.com/hyahm/scs","description":"service control service or script","fork":false,"url":"https://github.com/hyahm/scs","forks_url":"https://api.github.com/repos/hyahm/scs/forks","keys_url":"https://api.github.com/repos/hyahm/scs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hyahm/scs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hyahm/scs/teams","hooks_url":"https://api.github.com/repos/hyahm/scs/hooks","issue_events_url":"https://api.github.com/repos/hyahm/scs/issues/events{/number}","events_url":"https://api.github.com/repos/hyahm/scs/events","assignees_url":"https://api.github.com/repos/hyahm/scs/assignees{/user}","branches_url":"https://api.github.com/repos/hyahm/scs/branches{/branch}","tags_url":"https://api.github.com/repos/hyahm/scs/tags","blobs_url":"https://api.github.com/repos/hyahm/scs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hyahm/scs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hyahm/scs/git/refs{/sha}","trees_url":"https://api.github.com/repos/hyahm/scs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hyahm/scs/statuses/{sha}","languages_url":"https://api.github.com/repos/hyahm/scs/languages","stargazers_url":"https://api.github.com/repos/hyahm/scs/stargazers","contributors_url":"https://api.github.com/repos/hyahm/scs/contributors","subscribers_url":"https://api.github.com/repos/hyahm/scs/subscribers","subscription_url":"https://api.github.com/repos/hyahm/scs/subscription","commits_url":"https://api.github.com/repos/hyahm/scs/commits{/sha}","git_commits_url":"https://api.github.com/repos/hyahm/scs/git/commits{/sha}","comments_url":"https://api.github.com/repos/hyahm/scs/comments{/number}","issue_comment_url":"https://api.github.com/repos/hyahm/scs/issues/comments{/number}","contents_url":"https://api.github.com/repos/hyahm/scs/contents/{+path}","compare_url":"https://api.github.com/repos/hyahm/scs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hyahm/scs/merges","archive_url":"https://api.github.com/repos/hyahm/scs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hyahm/scs/downloads","issues_url":"https://api.github.com/repos/hyahm/scs/issues{/number}","pulls_url":"https://api.github.com/repos/hyahm/scs/pulls{/number}","milestones_url":"https://api.github.com/repos/hyahm/scs/milestones{/number}","notifications_url":"https://api.github.com/repos/hyahm/scs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hyahm/scs/labels{/name}","releases_url":"https://api.github.com/repos/hyahm/scs/releases{/id}","deployments_url":"https://api.github.com/repos/hyahm/scs/deployments","created_at":1585728709,"updated_at":"2020-09-17T04:06:39Z","pushed_at":1600315678,"git_url":"git://github.com/hyahm/scs.git","ssh_url":"git@github.com:hyahm/scs.git","clone_url":"https://github.com/hyahm/scs.git","svn_url":"https://github.com/hyahm/scs","homepage":"","size":5975,"stargazers_count":1,"watchers_count":1,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master","stargazers":1,"master_branch":"master"},"pusher":{"name":"hyahm","email":"cander_liubiao@126.com"},"sender":{"login":"hyahm","id":22030094,"node_id":"MDQ6VXNlcjIyMDMwMDk0","avatar_url":"https://avatars3.githubusercontent.com/u/22030094?v=4","gravatar_id":"","url":"https://api.github.com/users/hyahm","html_url":"https://github.com/hyahm","followers_url":"https://api.github.com/users/hyahm/followers","following_url":"https://api.github.com/users/hyahm/following{/other_user}","gists_url":"https://api.github.com/users/hyahm/gists{/gist_id}","starred_url":"https://api.github.com/users/hyahm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hyahm/subscriptions","organizations_url":"https://api.github.com/users/hyahm/orgs","repos_url":"https://api.github.com/users/hyahm/repos","events_url":"https://api.github.com/users/hyahm/events{/privacy}","received_events_url":"https://api.github.com/users/hyahm/received_events","type":"User","site_admin":false},"created":false,"deleted":false,"forced":false,"base_ref":null,"compare":"https://github.com/hyahm/scs/compare/fa899549d0bb...f2305457193c","commits":[{"id":"f2305457193c3e6088c8aac5eccc7ab4a7e58f01","tree_id":"6daf84143f85b4f1e59c9a05357c36f1d3358f91","distinct":true,"message":"test","timestamp":"2020-09-17T12:07:51+08:00","url":"https://github.com/hyahm/scs/commit/f2305457193c3e6088c8aac5eccc7ab4a7e58f01","author":{"name":"cander","email":"cander_liubiao@126.com","username":"hyahm"},"committer":{"name":"cander","email":"cander_liubiao@126.com","username":"hyahm"},"added":[],"removed":[],"modified":["README.md"]}],"head_commit":{"id":"f2305457193c3e6088c8aac5eccc7ab4a7e58f01","tree_id":"6daf84143f85b4f1e59c9a05357c36f1d3358f91","distinct":true,"message":"test","timestamp":"2020-09-17T12:07:51+08:00","url":"https://github.com/hyahm/scs/commit/f2305457193c3e6088c8aac5eccc7ab4a7e58f01","author":{"name":"cander","email":"cander_liubiao@126.com","username":"hyahm"},"committer":{"name":"cander","email":"cander_liubiao@126.com","username":"hyahm"},"added":[],"removed":[],"modified":["README.md"]}}`
// result := "99834aa2c22a0669e3a4a0d6cd6801cc686426aa"
s := hmac.New(sha1.New, []byte(token))
io.WriteString(s, x)
fmt.Printf("%x", s.Sum(nil))
}