mirror of
https://github.com/drone-plugins/drone-docker.git
synced 2026-06-04 18:24:24 +08:00
123a133f01
* feat: [CI-19349]: Added oidc support for azure connector * feat: [CI-19349]: Added env variables * feat: [CI-19349]: Added tests * Update cmd/drone-acr/main.go * Update cmd/drone-acr/main.go * feat: [CI-19349]: Added Debug statements --------- Co-authored-by: OP (oppenheimer) <21008429+Ompragash@users.noreply.github.com>
33 lines
1017 B
Go
33 lines
1017 B
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
func TestGetAuthInputValidation(t *testing.T) {
|
|
// missing tenant
|
|
if _, _, err := getAuth("client", "secret", "", "", "sub", "registry.azurecr.io"); err == nil {
|
|
t.Fatalf("expected error for missing tenantId")
|
|
}
|
|
// missing clientId
|
|
if _, _, err := getAuth("", "secret", "", "tenant", "sub", "registry.azurecr.io"); err == nil {
|
|
t.Fatalf("expected error for missing clientId")
|
|
}
|
|
// missing both secret and cert
|
|
if _, _, err := getAuth("client", "", "", "tenant", "sub", "registry.azurecr.io"); err == nil {
|
|
t.Fatalf("expected error for missing credentials")
|
|
}
|
|
}
|
|
|
|
func TestGetenvAuthorityHost(t *testing.T) {
|
|
os.Setenv("AZURE_AUTHORITY_HOST", "https://login.microsoftonline.us")
|
|
defer os.Unsetenv("AZURE_AUTHORITY_HOST")
|
|
|
|
got := getenv("AZURE_AUTHORITY_HOST")
|
|
if got != "https://login.microsoftonline.us" {
|
|
t.Fatalf("expected AZURE_AUTHORITY_HOST to be returned, got %q", got)
|
|
}
|
|
}
|
|
|