|
|
|
|
@ -188,6 +188,16 @@ func TestService_List(t *testing.T) {
|
|
|
|
|
_, err = authtoken.ListPage(ctx, []byte("some hash"), 1, filterFunc, tok, repo, nil)
|
|
|
|
|
require.ErrorContains(t, err, "missing scope ids")
|
|
|
|
|
})
|
|
|
|
|
t.Run("wrong token resource type", func(t *testing.T) {
|
|
|
|
|
t.Parallel()
|
|
|
|
|
filterFunc := func(_ context.Context, at *authtoken.AuthToken) (bool, error) {
|
|
|
|
|
return true, nil
|
|
|
|
|
}
|
|
|
|
|
tok, err := listtoken.NewPagination(ctx, fiveDaysAgo, resource.Target, []byte("some hash"), "some-id", fiveDaysAgo)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
_, err = authtoken.ListPage(ctx, []byte("some hash"), 1, filterFunc, tok, repo, []string{org.GetPublicId()})
|
|
|
|
|
require.ErrorContains(t, err, "token did not have an auth token resource type")
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
t.Run("ListRefresh validation", func(t *testing.T) {
|
|
|
|
|
t.Parallel()
|
|
|
|
|
@ -266,6 +276,16 @@ func TestService_List(t *testing.T) {
|
|
|
|
|
_, err = authtoken.ListRefresh(ctx, []byte("some hash"), 1, filterFunc, tok, repo, nil)
|
|
|
|
|
require.ErrorContains(t, err, "missing scope ids")
|
|
|
|
|
})
|
|
|
|
|
t.Run("wrong token resource type", func(t *testing.T) {
|
|
|
|
|
t.Parallel()
|
|
|
|
|
filterFunc := func(_ context.Context, at *authtoken.AuthToken) (bool, error) {
|
|
|
|
|
return true, nil
|
|
|
|
|
}
|
|
|
|
|
tok, err := listtoken.NewStartRefresh(ctx, fiveDaysAgo, resource.Target, []byte("some hash"), fiveDaysAgo, fiveDaysAgo)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
_, err = authtoken.ListRefresh(ctx, []byte("some hash"), 1, filterFunc, tok, repo, []string{org.GetPublicId()})
|
|
|
|
|
require.ErrorContains(t, err, "token did not have an auth token resource type")
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
t.Run("ListRefreshPage validation", func(t *testing.T) {
|
|
|
|
|
t.Parallel()
|
|
|
|
|
@ -344,6 +364,16 @@ func TestService_List(t *testing.T) {
|
|
|
|
|
_, err = authtoken.ListRefreshPage(ctx, []byte("some hash"), 1, filterFunc, tok, repo, nil)
|
|
|
|
|
require.ErrorContains(t, err, "missing scope ids")
|
|
|
|
|
})
|
|
|
|
|
t.Run("wrong token resource type", func(t *testing.T) {
|
|
|
|
|
t.Parallel()
|
|
|
|
|
filterFunc := func(_ context.Context, at *authtoken.AuthToken) (bool, error) {
|
|
|
|
|
return true, nil
|
|
|
|
|
}
|
|
|
|
|
tok, err := listtoken.NewRefresh(ctx, fiveDaysAgo, resource.Target, []byte("some hash"), fiveDaysAgo, fiveDaysAgo, fiveDaysAgo, "some other id", fiveDaysAgo)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
_, err = authtoken.ListRefreshPage(ctx, []byte("some hash"), 1, filterFunc, tok, repo, []string{org.GetPublicId()})
|
|
|
|
|
require.ErrorContains(t, err, "token did not have an auth token resource type")
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("simple pagination", func(t *testing.T) {
|
|
|
|
|
|