2021-09-16 08:53:11 -04:00
|
|
|
-- Copyright (c) HashiCorp, Inc.
|
|
|
|
|
-- SPDX-License-Identifier: BUSL-1.1
|
2023-02-02 17:15:17 -08:00
|
|
|
|
2021-09-16 08:53:11 -04:00
|
|
|
--- insert tests a simple insert of session_credential_dynamic
|
|
|
|
|
begin;
|
|
|
|
|
select plan(6);
|
|
|
|
|
|
|
|
|
|
select wtt_load('widgets', 'iam', 'kms', 'auth', 'hosts', 'targets', 'credentials');
|
2023-05-17 14:49:49 -04:00
|
|
|
|
2021-09-16 08:53:11 -04:00
|
|
|
select is(count(*), 0::bigint) from wh_credential_dimension where organization_id = 'o_____widget';
|
2023-05-17 14:49:49 -04:00
|
|
|
select is(count(*), 2::bigint) from wh_credential_group_membership where credential_group_key != 'no credentials' and credential_group_key != 'Unknown';
|
|
|
|
|
select is(count(*), 1::bigint) from wh_credential_group where key != 'no credentials' and key != 'Unknown';
|
2021-09-16 08:53:11 -04:00
|
|
|
|
|
|
|
|
--- insert single credential
|
|
|
|
|
insert into session
|
2022-11-11 12:18:51 -08:00
|
|
|
( project_id, target_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
2021-09-16 08:53:11 -04:00
|
|
|
values
|
2022-11-11 12:18:51 -08:00
|
|
|
('p____bwidget', 't_________wb', 'u_____walter', 'tok___walter', 'abc'::bytea, 'ep1', 's1____walter');
|
|
|
|
|
insert into session_host_set_host
|
|
|
|
|
(session_id, host_set_id, host_id)
|
|
|
|
|
values
|
|
|
|
|
('s1____walter', 's___1wb-sths', 'h_____wb__01');
|
2021-09-16 08:53:11 -04:00
|
|
|
insert into session_credential_dynamic
|
|
|
|
|
( session_id, library_id, credential_id, credential_purpose)
|
|
|
|
|
values
|
2022-07-19 15:16:24 -07:00
|
|
|
('s1____walter', 'vl______wvl1', null, 'brokered');
|
2021-09-16 08:53:11 -04:00
|
|
|
|
|
|
|
|
select is(count(*), 1::bigint) from wh_credential_dimension where organization_id = 'o_____widget';
|
2023-05-17 14:49:49 -04:00
|
|
|
select is(count(*), 3::bigint) from wh_credential_group_membership where credential_group_key != 'no credentials' and credential_group_key != 'Unknown';
|
|
|
|
|
select is(count(*), 2::bigint) from wh_credential_group where key != 'no credentials' and key != 'Unknown';
|
2021-09-16 08:53:11 -04:00
|
|
|
|
|
|
|
|
select * from finish();
|
|
|
|
|
rollback;
|