Skip to content

Commit

Permalink
internal/credential: use correct resource in tests (#4128)
Browse files Browse the repository at this point in the history
  • Loading branch information
johanbrandhorst committed Jan 4, 2024
1 parent 2923a25 commit 8b479a2
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions internal/credential/service_list_credentials_ext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func TestService_List(t *testing.T) {
filterFunc := func(_ context.Context, c credential.Static) (bool, error) {
return true, nil
}
tok, err := listtoken.NewPagination(ctx, fiveDaysAgo, resource.Target, []byte("some hash"), "some-id", fiveDaysAgo)
tok, err := listtoken.NewPagination(ctx, fiveDaysAgo, resource.Credential, []byte("some hash"), "some-id", fiveDaysAgo)
require.NoError(t, err)
_, err = credential.ListPage(ctx, nil, 1, filterFunc, tok, repo, credStore.GetPublicId())
require.ErrorContains(t, err, "missing grants hash")
Expand All @@ -155,7 +155,7 @@ func TestService_List(t *testing.T) {
filterFunc := func(_ context.Context, c credential.Static) (bool, error) {
return true, nil
}
tok, err := listtoken.NewPagination(ctx, fiveDaysAgo, resource.Target, []byte("some hash"), "some-id", fiveDaysAgo)
tok, err := listtoken.NewPagination(ctx, fiveDaysAgo, resource.Credential, []byte("some hash"), "some-id", fiveDaysAgo)
require.NoError(t, err)
_, err = credential.ListPage(ctx, []byte("some hash"), 0, filterFunc, tok, repo, credStore.GetPublicId())
require.ErrorContains(t, err, "page size must be at least 1")
Expand All @@ -165,14 +165,14 @@ func TestService_List(t *testing.T) {
filterFunc := func(_ context.Context, c credential.Static) (bool, error) {
return true, nil
}
tok, err := listtoken.NewPagination(ctx, fiveDaysAgo, resource.Target, []byte("some hash"), "some-id", fiveDaysAgo)
tok, err := listtoken.NewPagination(ctx, fiveDaysAgo, resource.Credential, []byte("some hash"), "some-id", fiveDaysAgo)
require.NoError(t, err)
_, err = credential.ListPage(ctx, []byte("some hash"), -1, filterFunc, tok, repo, credStore.GetPublicId())
require.ErrorContains(t, err, "page size must be at least 1")
})
t.Run("nil filter func", func(t *testing.T) {
t.Parallel()
tok, err := listtoken.NewPagination(ctx, fiveDaysAgo, resource.Target, []byte("some hash"), "some-id", fiveDaysAgo)
tok, err := listtoken.NewPagination(ctx, fiveDaysAgo, resource.Credential, []byte("some hash"), "some-id", fiveDaysAgo)
require.NoError(t, err)
_, err = credential.ListPage(ctx, []byte("some hash"), 1, nil, tok, repo, credStore.GetPublicId())
require.ErrorContains(t, err, "missing filter item callback")
Expand All @@ -190,7 +190,7 @@ func TestService_List(t *testing.T) {
filterFunc := func(_ context.Context, c credential.Static) (bool, error) {
return true, nil
}
tok, err := listtoken.NewStartRefresh(ctx, fiveDaysAgo, resource.Target, []byte("some hash"), fiveDaysAgo, fiveDaysAgo)
tok, err := listtoken.NewStartRefresh(ctx, fiveDaysAgo, resource.Credential, []byte("some hash"), fiveDaysAgo, fiveDaysAgo)
require.NoError(t, err)
_, err = credential.ListPage(ctx, []byte("some hash"), 1, filterFunc, tok, repo, credStore.GetPublicId())
require.ErrorContains(t, err, "token did not have a pagination token component")
Expand All @@ -200,7 +200,7 @@ func TestService_List(t *testing.T) {
filterFunc := func(_ context.Context, c credential.Static) (bool, error) {
return true, nil
}
tok, err := listtoken.NewPagination(ctx, fiveDaysAgo, resource.Target, []byte("some hash"), "some-id", fiveDaysAgo)
tok, err := listtoken.NewPagination(ctx, fiveDaysAgo, resource.Credential, []byte("some hash"), "some-id", fiveDaysAgo)
require.NoError(t, err)
_, err = credential.ListPage(ctx, []byte("some hash"), 1, filterFunc, tok, nil, credStore.GetPublicId())
require.ErrorContains(t, err, "missing service")
Expand All @@ -210,7 +210,7 @@ func TestService_List(t *testing.T) {
filterFunc := func(_ context.Context, c credential.Static) (bool, error) {
return true, nil
}
tok, err := listtoken.NewPagination(ctx, fiveDaysAgo, resource.Target, []byte("some hash"), "some-id", fiveDaysAgo)
tok, err := listtoken.NewPagination(ctx, fiveDaysAgo, resource.Credential, []byte("some hash"), "some-id", fiveDaysAgo)
require.NoError(t, err)
_, err = credential.ListPage(ctx, []byte("some hash"), 1, filterFunc, tok, repo, "")
require.ErrorContains(t, err, "missing credential store ID")
Expand All @@ -223,7 +223,7 @@ func TestService_List(t *testing.T) {
filterFunc := func(_ context.Context, c credential.Static) (bool, error) {
return true, nil
}
tok, err := listtoken.NewStartRefresh(ctx, fiveDaysAgo, resource.Target, []byte("some hash"), fiveDaysAgo, fiveDaysAgo)
tok, err := listtoken.NewStartRefresh(ctx, fiveDaysAgo, resource.Credential, []byte("some hash"), fiveDaysAgo, fiveDaysAgo)
require.NoError(t, err)
_, err = credential.ListRefresh(ctx, nil, 1, filterFunc, tok, repo, credStore.GetPublicId())
require.ErrorContains(t, err, "missing grants hash")
Expand All @@ -233,7 +233,7 @@ func TestService_List(t *testing.T) {
filterFunc := func(_ context.Context, c credential.Static) (bool, error) {
return true, nil
}
tok, err := listtoken.NewStartRefresh(ctx, fiveDaysAgo, resource.Target, []byte("some hash"), fiveDaysAgo, fiveDaysAgo)
tok, err := listtoken.NewStartRefresh(ctx, fiveDaysAgo, resource.Credential, []byte("some hash"), fiveDaysAgo, fiveDaysAgo)
require.NoError(t, err)
_, err = credential.ListRefresh(ctx, []byte("some hash"), 0, filterFunc, tok, repo, credStore.GetPublicId())
require.ErrorContains(t, err, "page size must be at least 1")
Expand All @@ -243,14 +243,14 @@ func TestService_List(t *testing.T) {
filterFunc := func(_ context.Context, c credential.Static) (bool, error) {
return true, nil
}
tok, err := listtoken.NewStartRefresh(ctx, fiveDaysAgo, resource.Target, []byte("some hash"), fiveDaysAgo, fiveDaysAgo)
tok, err := listtoken.NewStartRefresh(ctx, fiveDaysAgo, resource.Credential, []byte("some hash"), fiveDaysAgo, fiveDaysAgo)
require.NoError(t, err)
_, err = credential.ListRefresh(ctx, []byte("some hash"), -1, filterFunc, tok, repo, credStore.GetPublicId())
require.ErrorContains(t, err, "page size must be at least 1")
})
t.Run("nil filter func", func(t *testing.T) {
t.Parallel()
tok, err := listtoken.NewStartRefresh(ctx, fiveDaysAgo, resource.Target, []byte("some hash"), fiveDaysAgo, fiveDaysAgo)
tok, err := listtoken.NewStartRefresh(ctx, fiveDaysAgo, resource.Credential, []byte("some hash"), fiveDaysAgo, fiveDaysAgo)
require.NoError(t, err)
_, err = credential.ListRefresh(ctx, []byte("some hash"), 1, nil, tok, repo, credStore.GetPublicId())
require.ErrorContains(t, err, "missing filter item callback")
Expand All @@ -268,7 +268,7 @@ func TestService_List(t *testing.T) {
filterFunc := func(_ context.Context, c credential.Static) (bool, error) {
return true, nil
}
tok, err := listtoken.NewStartRefresh(ctx, fiveDaysAgo, resource.Target, []byte("some hash"), fiveDaysAgo, fiveDaysAgo)
tok, err := listtoken.NewStartRefresh(ctx, fiveDaysAgo, resource.Credential, []byte("some hash"), fiveDaysAgo, fiveDaysAgo)
require.NoError(t, err)
_, err = credential.ListRefresh(ctx, []byte("some hash"), 1, filterFunc, tok, nil, credStore.GetPublicId())
require.ErrorContains(t, err, "missing service")
Expand All @@ -278,7 +278,7 @@ func TestService_List(t *testing.T) {
filterFunc := func(_ context.Context, c credential.Static) (bool, error) {
return true, nil
}
tok, err := listtoken.NewStartRefresh(ctx, fiveDaysAgo, resource.Target, []byte("some hash"), fiveDaysAgo, fiveDaysAgo)
tok, err := listtoken.NewStartRefresh(ctx, fiveDaysAgo, resource.Credential, []byte("some hash"), fiveDaysAgo, fiveDaysAgo)
require.NoError(t, err)
_, err = credential.ListRefresh(ctx, []byte("some hash"), 1, filterFunc, tok, repo, "")
require.ErrorContains(t, err, "missing credential store ID")
Expand All @@ -291,7 +291,7 @@ func TestService_List(t *testing.T) {
filterFunc := func(_ context.Context, c credential.Static) (bool, error) {
return true, nil
}
tok, err := listtoken.NewRefresh(ctx, fiveDaysAgo, resource.Target, []byte("some hash"), fiveDaysAgo, fiveDaysAgo, fiveDaysAgo, "some other id", fiveDaysAgo)
tok, err := listtoken.NewRefresh(ctx, fiveDaysAgo, resource.Credential, []byte("some hash"), fiveDaysAgo, fiveDaysAgo, fiveDaysAgo, "some other id", fiveDaysAgo)
require.NoError(t, err)
_, err = credential.ListRefreshPage(ctx, nil, 1, filterFunc, tok, repo, credStore.GetPublicId())
require.ErrorContains(t, err, "missing grants hash")
Expand All @@ -301,7 +301,7 @@ func TestService_List(t *testing.T) {
filterFunc := func(_ context.Context, c credential.Static) (bool, error) {
return true, nil
}
tok, err := listtoken.NewRefresh(ctx, fiveDaysAgo, resource.Target, []byte("some hash"), fiveDaysAgo, fiveDaysAgo, fiveDaysAgo, "some other id", fiveDaysAgo)
tok, err := listtoken.NewRefresh(ctx, fiveDaysAgo, resource.Credential, []byte("some hash"), fiveDaysAgo, fiveDaysAgo, fiveDaysAgo, "some other id", fiveDaysAgo)
require.NoError(t, err)
_, err = credential.ListRefreshPage(ctx, []byte("some hash"), 0, filterFunc, tok, repo, credStore.GetPublicId())
require.ErrorContains(t, err, "page size must be at least 1")
Expand All @@ -311,14 +311,14 @@ func TestService_List(t *testing.T) {
filterFunc := func(_ context.Context, c credential.Static) (bool, error) {
return true, nil
}
tok, err := listtoken.NewRefresh(ctx, fiveDaysAgo, resource.Target, []byte("some hash"), fiveDaysAgo, fiveDaysAgo, fiveDaysAgo, "some other id", fiveDaysAgo)
tok, err := listtoken.NewRefresh(ctx, fiveDaysAgo, resource.Credential, []byte("some hash"), fiveDaysAgo, fiveDaysAgo, fiveDaysAgo, "some other id", fiveDaysAgo)
require.NoError(t, err)
_, err = credential.ListRefreshPage(ctx, []byte("some hash"), -1, filterFunc, tok, repo, credStore.GetPublicId())
require.ErrorContains(t, err, "page size must be at least 1")
})
t.Run("nil filter func", func(t *testing.T) {
t.Parallel()
tok, err := listtoken.NewRefresh(ctx, fiveDaysAgo, resource.Target, []byte("some hash"), fiveDaysAgo, fiveDaysAgo, fiveDaysAgo, "some other id", fiveDaysAgo)
tok, err := listtoken.NewRefresh(ctx, fiveDaysAgo, resource.Credential, []byte("some hash"), fiveDaysAgo, fiveDaysAgo, fiveDaysAgo, "some other id", fiveDaysAgo)
require.NoError(t, err)
_, err = credential.ListRefreshPage(ctx, []byte("some hash"), 1, nil, tok, repo, credStore.GetPublicId())
require.ErrorContains(t, err, "missing filter item callback")
Expand All @@ -336,7 +336,7 @@ func TestService_List(t *testing.T) {
filterFunc := func(_ context.Context, c credential.Static) (bool, error) {
return true, nil
}
tok, err := listtoken.NewPagination(ctx, fiveDaysAgo, resource.Target, []byte("some hash"), "some-id", fiveDaysAgo)
tok, err := listtoken.NewPagination(ctx, fiveDaysAgo, resource.Credential, []byte("some hash"), "some-id", fiveDaysAgo)
require.NoError(t, err)
_, err = credential.ListRefreshPage(ctx, []byte("some hash"), 1, filterFunc, tok, repo, credStore.GetPublicId())
require.ErrorContains(t, err, "token did not have a refresh token component")
Expand All @@ -346,7 +346,7 @@ func TestService_List(t *testing.T) {
filterFunc := func(_ context.Context, c credential.Static) (bool, error) {
return true, nil
}
tok, err := listtoken.NewRefresh(ctx, fiveDaysAgo, resource.Target, []byte("some hash"), fiveDaysAgo, fiveDaysAgo, fiveDaysAgo, "some other id", fiveDaysAgo)
tok, err := listtoken.NewRefresh(ctx, fiveDaysAgo, resource.Credential, []byte("some hash"), fiveDaysAgo, fiveDaysAgo, fiveDaysAgo, "some other id", fiveDaysAgo)
require.NoError(t, err)
_, err = credential.ListRefreshPage(ctx, []byte("some hash"), 1, filterFunc, tok, nil, credStore.GetPublicId())
require.ErrorContains(t, err, "missing service")
Expand All @@ -356,7 +356,7 @@ func TestService_List(t *testing.T) {
filterFunc := func(_ context.Context, c credential.Static) (bool, error) {
return true, nil
}
tok, err := listtoken.NewRefresh(ctx, fiveDaysAgo, resource.Target, []byte("some hash"), fiveDaysAgo, fiveDaysAgo, fiveDaysAgo, "some other id", fiveDaysAgo)
tok, err := listtoken.NewRefresh(ctx, fiveDaysAgo, resource.Credential, []byte("some hash"), fiveDaysAgo, fiveDaysAgo, fiveDaysAgo, "some other id", fiveDaysAgo)
require.NoError(t, err)
_, err = credential.ListRefreshPage(ctx, []byte("some hash"), 1, filterFunc, tok, repo, "")
require.ErrorContains(t, err, "missing credential store ID")
Expand Down

0 comments on commit 8b479a2

Please sign in to comment.