-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils_test.go
22 lines (18 loc) · 995 Bytes
/
utils_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package hannibal
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestIsActivityPubContentType(t *testing.T) {
require.True(t, IsActivityPubContentType("application/json"))
require.True(t, IsActivityPubContentType("application/json; everything after the semicolon is ignored"))
require.True(t, IsActivityPubContentType("application/json; whocares=notme"))
require.True(t, IsActivityPubContentType("application/activity+json"))
require.True(t, IsActivityPubContentType("application/activity+json; charset=utf-8"))
require.True(t, IsActivityPubContentType("application/ld+json"))
require.True(t, IsActivityPubContentType("application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""))
require.False(t, IsActivityPubContentType("literally anything else"))
require.False(t, IsActivityPubContentType("application/xml"))
require.False(t, IsActivityPubContentType("application/xml; whocares=notme"))
require.False(t, IsActivityPubContentType("image/webp"))
}