Skip to content

Commit

Permalink
Add end-to-end test for LDAP
Browse files Browse the repository at this point in the history
* use LDAP fake server package
* expose config from YAML function
* update go repository and deps list
  • Loading branch information
JonasScharpf committed Apr 18, 2024
1 parent 6771bab commit 4ef6685
Show file tree
Hide file tree
Showing 7 changed files with 368 additions and 3 deletions.
6 changes: 4 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,16 @@ go_repository(

go_repository(
name = "in_gopkg_asn1_ber_v1",
commit = "f715ec2f112d1e4195b827ad68cf44017a3ef2b1",
importpath = "gopkg.in/asn1-ber.v1",
sum = "h1:TxyelI5cVkbREznMhfzycHdkp5cLA7DpE+GKjSslYhM=",
version = "v1.0.0-20181015200546-f715ec2f112d",
)

go_repository(
name = "in_gopkg_ldap_v3",
commit = "9f0d712775a0973b7824a1585a86a4ea1d5263d9",
importpath = "gopkg.in/ldap.v3",
sum = "h1:YKRHW/2sIl05JsCtx/5ZuUueFuJyoj/6+DGXe3wp6ro=",
version = "v3.0.3",
)

gazelle_dependencies()
Expand Down
4 changes: 4 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ func newFromYaml(data []byte) (*Config, error) {
return &c, nil
}

func NewConfigFromYaml(data []byte) (*Config, error) {
return newFromYaml(data)
}

func validateConfig(c *Config) error {
if c.Dir == "" {
return errors.New("The 'dir' flag/key is required")
Expand Down
34 changes: 34 additions & 0 deletions deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ def go_dependencies():
sum = "h1:s6gZFSlWYmbqAuRjVTiNNhvNRfY2Wxp9nhfyel4rklc=",
version = "v0.0.0-20211218093645-b94a6e3cc137",
)
go_repository(
name = "com_github_alexbrainman_sspi",
importpath = "github.com/alexbrainman/sspi",
sum = "h1:Kk6a4nehpJ3UuJRqlA3JxYxBZEqCeOmATOvrbT4p9RA=",
version = "v0.0.0-20210105120005-909beea2cc74",
)

go_repository(
name = "com_github_andybalholm_brotli",
importpath = "github.com/andybalholm/brotli",
Expand Down Expand Up @@ -65,6 +72,13 @@ def go_dependencies():
sum = "h1:QSdcrd/UFJv6Bp/CfoVf2SrENpFn9P6Yh8yb+xNhYMM=",
version = "v0.4.1",
)
go_repository(
name = "com_github_azure_go_ntlmssp",
importpath = "github.com/Azure/go-ntlmssp",
sum = "h1:mFRzDkZVAjdal+s7s0MwaRv9igoPqLRdzOLzw/8Xvq8=",
version = "v0.0.0-20221128193559-754e69321358",
)

go_repository(
name = "com_github_azuread_microsoft_authentication_library_for_go",
importpath = "github.com/AzureAD/microsoft-authentication-library-for-go",
Expand Down Expand Up @@ -230,6 +244,13 @@ def go_dependencies():
sum = "h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg=",
version = "v1.9.1",
)
go_repository(
name = "com_github_go_asn1_ber_asn1_ber",
importpath = "github.com/go-asn1-ber/asn1-ber",
sum = "h1:MNHlNMBDgEKD4TcKr36vQN68BA00aDfjIt3/bD50WnA=",
version = "v1.5.5",
)

go_repository(
name = "com_github_go_chi_chi_v4",
importpath = "github.com/go-chi/chi/v4",
Expand All @@ -243,6 +264,12 @@ def go_dependencies():
sum = "h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU=",
version = "v0.2.1",
)
go_repository(
name = "com_github_go_ldap_ldap_v3",
importpath = "github.com/go-ldap/ldap/v3",
sum = "h1:ert95MdbiG7aWo/oPYp9btL3KJlMPKnP58r09rI8T+A=",
version = "v3.4.6",
)

go_repository(
name = "com_github_go_logfmt_logfmt",
Expand Down Expand Up @@ -390,6 +417,13 @@ def go_dependencies():
sum = "h1:Qbeh12Vq6BxURXT1qZBRHsDxeURB8ztcL6f3EXSGeHk=",
version = "v1.1.3",
)
go_repository(
name = "com_github_jonasscharpf_godap",
importpath = "github.com/JonasScharpf/godap",
sum = "h1:7L5zT1awL4RZeLtT4vp+BlRoTrFBbRtMFOZMQCqub7I=",
version = "v0.0.0-20240417153024-2d460c2776c0",
)

go_repository(
name = "com_github_josharian_intern",
importpath = "github.com/josharian/intern",
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ require (
github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1 // indirect
github.com/JonasScharpf/godap v0.0.0-20240417153024-2d460c2776c0 // indirect
github.com/aws/aws-sdk-go v1.44.256 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 h1:mFRzDkZVAjdal+
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU=
github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1 h1:BWe8a+f/t+7KY7zH2mqygeUD0t8hNFXe08p1Pb3/jKE=
github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4=
github.com/JonasScharpf/godap v0.0.0-20240417153024-2d460c2776c0 h1:7L5zT1awL4RZeLtT4vp+BlRoTrFBbRtMFOZMQCqub7I=
github.com/JonasScharpf/godap v0.0.0-20240417153024-2d460c2776c0/go.mod h1:K5gGJQ/vwxHEUWBYv7ciUOgw94MYrGCoy5JX/hjSJkY=
github.com/abbot/go-http-auth v0.4.1-0.20220112235402-e1cee1c72f2f h1:R2ZVGCZzU95oXFJxncosHS9LsX8N4/MYUdGGWOb2cFk=
github.com/abbot/go-http-auth v0.4.1-0.20220112235402-e1cee1c72f2f/go.mod h1:l2P3JyHa+fjy5Bxol6y1u2o4DV/mv3QMBdBu2cNR53w=
github.com/alexbrainman/sspi v0.0.0-20210105120005-909beea2cc74/go.mod h1:cEWa1LVoE5KvSD9ONXsZrj0z6KqySlCCNKHlLzbqAt4=
Expand Down
12 changes: 11 additions & 1 deletion ldap/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "go_default_library",
Expand All @@ -11,3 +11,13 @@ go_library(
"@in_gopkg_ldap_v3//:go_default_library",
],
)

go_test(
name = "go_default_test",
srcs = ["ldap_test.go"],
embed = [":go_default_library"],
deps = [
"//config:go_default_library",
"@com_github_jonasscharpf_godap//godap:go_default_library",
],
)
Loading

0 comments on commit 4ef6685

Please sign in to comment.