Skip to content

Commit

Permalink
Changes function name from removeNewLine to getFirstLine
Browse files Browse the repository at this point in the history
The name had do look more constructive and getFirstLine
was proposed so i changed it.

Signed-off-by: Martin Dekov (VMware) <[email protected]>
  • Loading branch information
martindekov authored and alexellis committed Jul 6, 2018
1 parent 772928d commit fa1f0e6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func hmacValidation() bool {
return len(val) > 0 && (val == "1" || val == "true")
}

func removeNewLine(secret []byte) []byte {
func getFirstLine(secret []byte) []byte {
stringSecret := string(secret)
if newLine := strings.Index(stringSecret, "\n"); newLine != -1 {
secret = secret[:newLine]
Expand Down Expand Up @@ -78,7 +78,7 @@ func main() {
os.Exit(1)
}

secretKeyBytes = removeNewLine(secretKeyBytes)
secretKeyBytes = getFirstLine(secretKeyBytes)

err := hmac.Validate(bytesIn, xHubSignature, string(secretKeyBytes))
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import "testing"

func Test_removeNewLine(t *testing.T) {
func Test_getFirstLine(t *testing.T) {
var exampleSecrets = []struct {
secret string
expectedByte string
Expand Down Expand Up @@ -32,7 +32,7 @@ func Test_removeNewLine(t *testing.T) {
for _, test := range exampleSecrets {

t.Run(string(test.secret), func(t *testing.T) {
stringNoLines := removeNewLine([]byte(test.secret))
stringNoLines := getFirstLine([]byte(test.secret))
if test.expectedByte != string(stringNoLines) {
t.Errorf("String after removal - wanted: \"%s\", got \"%s\"", test.expectedByte, test.secret)
}
Expand Down

0 comments on commit fa1f0e6

Please sign in to comment.