2025-06-02 22:29:10 +02:00
|
|
|
// Copyright 2025 The Forgejo Authors. All rights reserved.
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
package forgefed
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"forgejo.org/modules/validation"
|
|
|
|
|
|
|
|
ap "github.com/go-ap/activitypub"
|
2025-08-06 16:16:13 +02:00
|
|
|
"github.com/stretchr/testify/assert"
|
2025-06-02 22:29:10 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func Test_ForgeUserActivityValidation(t *testing.T) {
|
|
|
|
note := ForgeUserActivityNote{}
|
|
|
|
note.Type = "Note"
|
|
|
|
note.Content = ap.NaturalLanguageValues{
|
|
|
|
{
|
|
|
|
Ref: ap.NilLangRef,
|
|
|
|
Value: ap.Content("Any Content!"),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
note.URL = ap.IRI("example.org/user-id/57")
|
|
|
|
|
|
|
|
sut := ForgeUserActivity{}
|
|
|
|
sut.Type = "Create"
|
|
|
|
sut.Actor = ap.IRI("example.org/user-id/23")
|
|
|
|
sut.CC = ap.ItemCollection{
|
|
|
|
ap.IRI("example.org/registration/public#2nd"),
|
|
|
|
}
|
|
|
|
sut.To = ap.ItemCollection{
|
|
|
|
ap.IRI("example.org/registration/public"),
|
|
|
|
}
|
|
|
|
|
|
|
|
sut.Note = note
|
|
|
|
|
2025-08-06 16:16:13 +02:00
|
|
|
valid, _ := validation.IsValid(sut)
|
|
|
|
assert.True(t, valid, "sut expected to be valid: %v\n", sut.Validate())
|
2025-06-02 22:29:10 +02:00
|
|
|
}
|