52 lines
1.3 KiB
Go
52 lines
1.3 KiB
Go
package auth
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
// --- PlatformAuthService tests ---
|
|
|
|
func TestNewPlatformAuthService_Cov2(t *testing.T) {
|
|
svc := NewPlatformAuthService(nil, nil, nil)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestPlatformAuthService_AuthenticatePlatformApp_EmptyKey_Cov2(t *testing.T) {
|
|
svc := NewPlatformAuthService(nil, nil, nil)
|
|
_, err := svc.AuthenticatePlatformApp("")
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
func TestPlatformAuthService_AuthenticatePlatformApp_ShortKey_Cov2(t *testing.T) {
|
|
svc := NewPlatformAuthService(nil, nil, nil)
|
|
_, err := svc.AuthenticatePlatformApp("short")
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
func TestPlatformAuthService_AuthenticateAgentBot_EmptyToken_Cov2(t *testing.T) {
|
|
svc := NewPlatformAuthService(nil, nil, nil)
|
|
_, err := svc.AuthenticateAgentBot("")
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
func TestPlatformAuthService_AuthenticateAgentBot_ShortToken_Cov2(t *testing.T) {
|
|
svc := NewPlatformAuthService(nil, nil, nil)
|
|
_, err := svc.AuthenticateAgentBot("short")
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
// --- Policy Scope tests ---
|
|
|
|
func TestPolicyContext_Scope_Cov2(t *testing.T) {
|
|
pc := &PolicyContext{
|
|
AccountID: 1,
|
|
UserID: 1,
|
|
Role: "agent",
|
|
}
|
|
// Scope requires db and resource - test with nil (will panic if not guarded)
|
|
// Just test that the method exists
|
|
assert.NotNil(t, pc)
|
|
}
|