mirror of
https://github.com/bolkedebruin/rdpgw.git
synced 2025-08-13 04:19:19 +02:00
* Support for NTLM authentication added To support NTLM authentication, a database is added as an authentication source. Currently, only the configuration file is supported as a database. Database authentication supports Basic and NTLM authentication protcols. ServerConfig.BasicAuthEnabled renamed to LocalEnabled as Basic auth can be used with NTLM or Local.
43 lines
966 B
Go
43 lines
966 B
Go
package database
|
|
|
|
import (
|
|
"github.com/bolkedebruin/rdpgw/cmd/auth/config"
|
|
"testing"
|
|
)
|
|
|
|
func createTestDatabase () (Database) {
|
|
var users = []config.UserConfig{}
|
|
|
|
user1 := config.UserConfig{}
|
|
user1.Username = "my_username"
|
|
user1.Password = "my_password"
|
|
users = append(users, user1)
|
|
|
|
user2 := config.UserConfig{}
|
|
user2.Username = "my_username2"
|
|
user2.Password = "my_password2"
|
|
users = append(users, user2)
|
|
|
|
config := NewConfig(users)
|
|
|
|
return config
|
|
}
|
|
|
|
func TestDatabaseConfigValidUsername(t *testing.T) {
|
|
database := createTestDatabase()
|
|
|
|
if database.GetPassword("my_username") != "my_password" {
|
|
t.Fatalf("Wrong password returned")
|
|
}
|
|
if database.GetPassword("my_username2") != "my_password2" {
|
|
t.Fatalf("Wrong password returned")
|
|
}
|
|
}
|
|
|
|
func TestDatabaseInvalidUsername(t *testing.T) {
|
|
database := createTestDatabase()
|
|
|
|
if database.GetPassword("my_invalid_username") != "" {
|
|
t.Fatalf("Non empty password returned for invalid username")
|
|
}
|
|
}
|