Skip to content

Commit

Permalink
add: auth test module
Browse files Browse the repository at this point in the history
  • Loading branch information
amirhnajafiz committed Aug 24, 2023
1 parent fd4007f commit a067d99
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions internal/auth_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package internal

import "testing"

func TestEmptyAuth(t *testing.T) {
a := auth{
username: " ",
password: " ",
}

valid := ""
invalid := "take:me"

if !a.authenticate(valid) {
t.Error("failed to check empty token")
}

if !a.authenticate(invalid) {
t.Error("failed to check free token")
}
}

func TestAuth(t *testing.T) {
a := auth{
username: "root",
password: "password",
}

valid := "root:password"
invalid := "take:me"

if !a.authenticate(valid) {
t.Error("failed to check true token")
}

if a.authenticate(invalid) {
t.Error("failed to check free token")
}
}

0 comments on commit a067d99

Please sign in to comment.