feat(db): Support a direct address association to a Target
This commit is contained in:
1 parent
1f9063e042
commit
3dd4b1c63d
35 files changed
+1330
-88
No files matched your search
@@ -10,6 +10,7 @@ begin;
|
||||
alter column credential_group_key drop default;
|
||||
|
||||
-- replaces function from 15/01_wh_rename_key_columns.up.sql
|
||||
-- replaced function in 70/03_wh_sessions.up.sql
|
||||
drop trigger wh_insert_session on session;
|
||||
drop function wh_insert_session;
|
||||
|
||||
|
||||
@@ -70,6 +70,7 @@ begin;
|
||||
|
||||
|
||||
-- replaces function from 15/02_wh_rename_key_columns.up.sql
|
||||
-- replaced function in 70/03_wh_sessions.up.sql
|
||||
-- adds the network address key to the host dimension table.
|
||||
drop function wh_upsert_host;
|
||||
create function wh_upsert_host(p_host_id wt_public_id, p_host_set_id wt_public_id, p_target_id wt_public_id) returns wh_dim_key
|
||||
|
||||
@@ -82,6 +82,7 @@ begin;
|
||||
-- warehouse
|
||||
|
||||
-- Replaces whx_host_dimension_source defined in 26/02_wh_network_address_dimensions.up.sql.
|
||||
-- Replaced view in 70/03_wh_sessions.up.sql
|
||||
drop view whx_host_dimension_source;
|
||||
create view whx_host_dimension_source as
|
||||
select -- id is the first column in the target view
|
||||
|
||||
@@ -35,6 +35,7 @@ begin;
|
||||
$$ language plpgsql;
|
||||
|
||||
-- Replaces trigger from 01/50_session.up.sql
|
||||
-- Replaced trigger in 70/02_sessions.up.sql
|
||||
create or replace function insert_session() returns trigger
|
||||
as $$
|
||||
begin
|
||||
|
||||
+1
@@ -32,6 +32,7 @@ begin;
|
||||
on update cascade;
|
||||
|
||||
-- Replaces trigger from 44/04_session.up.sql
|
||||
-- Replaced in 70/02_sessions.up.sql
|
||||
-- Adding a foreign key reference to the kms key means we have
|
||||
-- to set the key_id to null when the scope_id is set to null,
|
||||
-- otherwise we can't delete scopes with sessions, since deleting
|
||||
|
||||
+1
@@ -86,6 +86,7 @@ select public_id,
|
||||
from target_tcp;
|
||||
|
||||
-- Replaces view from 56/06_add_session_private_key_column.up.sql
|
||||
-- Replaced in 70/02_sessions.up.sql
|
||||
drop view session_list;
|
||||
create view session_list as
|
||||
select
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
begin;
|
||||
|
||||
create table target_address (
|
||||
target_id wt_public_id primary key,
|
||||
address text not null
|
||||
-- the following constraints are used to validate the length requirements of a dns name
|
||||
-- note the address column can also contain other network types such as ipv4
|
||||
constraint address_must_be_more_than_2_characters
|
||||
check(length(trim(address)) > 2)
|
||||
constraint address_must_be_less_than_256_characters
|
||||
check(length(trim(address)) < 256),
|
||||
constraint target_fkey foreign key (target_id)
|
||||
references target (public_id)
|
||||
on delete cascade
|
||||
on update cascade
|
||||
);
|
||||
comment on table target_address is
|
||||
'target_address entries represent a network address assigned to a target.';
|
||||
|
||||
create trigger immutable_columns before update on target_address
|
||||
for each row execute function immutable_columns('target_id');
|
||||
|
||||
insert into oplog_ticket (name, version)
|
||||
values
|
||||
('target_address', 1);
|
||||
|
||||
commit;
|
||||
@@ -0,0 +1,218 @@
|
||||
begin;
|
||||
|
||||
-- Replaces trigger from 56/02_add_data_key_foreign_key_references.up.sql
|
||||
drop trigger cancel_session_with_null_fk on session;
|
||||
create or replace function cancel_session_with_null_fk() returns trigger
|
||||
as $$
|
||||
begin
|
||||
-- Note that we need each of these to run in case
|
||||
-- more than one of them is null.
|
||||
if new.auth_token_id is null then
|
||||
perform cancel_session(new.public_id);
|
||||
end if;
|
||||
if new.project_id is null then
|
||||
-- Setting the key_id to null will allow the scope
|
||||
-- to cascade delete its keys.
|
||||
new.key_id = null;
|
||||
perform cancel_session(new.public_id);
|
||||
end if;
|
||||
if new.target_id is null then
|
||||
perform cancel_session(new.public_id);
|
||||
end if;
|
||||
if new.user_id is null then
|
||||
perform cancel_session(new.public_id);
|
||||
end if;
|
||||
return new;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
create trigger cancel_session_with_null_fk before update of auth_token_id, project_id, target_id, user_id on session
|
||||
for each row execute procedure cancel_session_with_null_fk();
|
||||
|
||||
create table session_target_address (
|
||||
session_id wt_public_id primary key,
|
||||
target_id wt_public_id,
|
||||
-- the following foreign key constraint is set to null on a delete
|
||||
-- because we want to be able to invoke a trigger to call cancel_session
|
||||
-- when the references column is deleted
|
||||
-- rather than canceling a session for any reason that may cause a row to be deleted.
|
||||
constraint target_address_fkey foreign key (target_id)
|
||||
references target_address (target_id)
|
||||
on delete set null
|
||||
on update cascade,
|
||||
constraint session_fkey foreign key (session_id)
|
||||
references session (public_id)
|
||||
on delete cascade
|
||||
on update cascade,
|
||||
constraint session_target_address_session_id_target_id_uq
|
||||
unique(session_id, target_id)
|
||||
);
|
||||
comment on table session_target_address is
|
||||
'session_target_address entries represent a session that is using a network address that is assigned directly to a Target.';
|
||||
|
||||
create trigger immutable_columns before update on session_target_address
|
||||
for each row execute procedure immutable_columns('session_id');
|
||||
|
||||
create function cancel_session_with_null_target_address_fk() returns trigger
|
||||
as $$
|
||||
begin
|
||||
if new.target_id is null then
|
||||
perform cancel_session(new.session_id);
|
||||
delete from session_target_address where session_id = new.session_id;
|
||||
end if;
|
||||
return new;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
create trigger cancel_session_with_null_target_address_fk after update of target_id on session_target_address
|
||||
for each row execute procedure cancel_session_with_null_target_address_fk();
|
||||
|
||||
create function insert_session_target_address() returns trigger
|
||||
as $$
|
||||
begin
|
||||
if new.target_id is null then
|
||||
raise exception 'target_id is null';
|
||||
end if;
|
||||
return new;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
create trigger insert_session_target_address before insert on session_target_address
|
||||
for each row execute procedure insert_session_target_address();
|
||||
|
||||
create table session_host_set_host (
|
||||
session_id wt_public_id primary key,
|
||||
host_set_id wt_public_id,
|
||||
host_id wt_public_id,
|
||||
-- the following foreign key constraints for host_set_id & host_id is set to null on a delete
|
||||
-- because we want to be able to invoke a trigger to call cancel_session
|
||||
-- when the references column is deleted
|
||||
-- rather than canceling a session for any reason that may cause a row to be deleted.
|
||||
constraint host_set_fkey foreign key (host_set_id)
|
||||
references host_set (public_id)
|
||||
on delete set null
|
||||
on update cascade,
|
||||
constraint host_fkey foreign key (host_id)
|
||||
references host (public_id)
|
||||
on delete set null
|
||||
on update cascade,
|
||||
constraint session_fkey foreign key (session_id)
|
||||
references session (public_id)
|
||||
on delete cascade
|
||||
on update cascade,
|
||||
constraint session_host_set_host_session_id_host_set_id_host_id_uq
|
||||
unique(session_id, host_set_id, host_id)
|
||||
);
|
||||
comment on table session_host_set_host is
|
||||
'session_host_set entries represent a session that is using a Host Set.';
|
||||
|
||||
create trigger immutable_columns before update on session_host_set_host
|
||||
for each row execute procedure immutable_columns('session_id');
|
||||
|
||||
create function cancel_session_with_null_host_source_fk() returns trigger
|
||||
as $$
|
||||
begin
|
||||
if new.host_set_id is null or new.host_id is null then
|
||||
perform cancel_session(new.session_id);
|
||||
delete from session_host_set_host where session_id = new.session_id;
|
||||
end if;
|
||||
return new;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
create trigger cancel_session_with_null_host_source_fk after update of host_set_id, host_id on session_host_set_host
|
||||
for each row execute procedure cancel_session_with_null_host_source_fk();
|
||||
|
||||
create function insert_session_host_set_host() returns trigger
|
||||
as $$
|
||||
begin
|
||||
if new.host_set_id is null then
|
||||
raise exception 'host_set_id is null';
|
||||
end if;
|
||||
if new.host_id is null then
|
||||
raise exception 'host_id is null';
|
||||
end if;
|
||||
return new;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
create trigger insert_session_host_set_host before insert on session_host_set_host
|
||||
for each row execute procedure insert_session_host_set_host();
|
||||
|
||||
drop view session_list;
|
||||
alter table session
|
||||
drop constraint session_host_id_fkey,
|
||||
drop constraint session_host_set_id_fkey,
|
||||
drop column host_id,
|
||||
drop column host_set_id
|
||||
;
|
||||
|
||||
-- Replaces trigger from 44/04_sessions.up.sql
|
||||
drop trigger insert_session on session;
|
||||
create or replace function insert_session() returns trigger
|
||||
as $$
|
||||
begin
|
||||
case
|
||||
when new.user_id is null then
|
||||
raise exception 'user_id is null';
|
||||
when new.target_id is null then
|
||||
raise exception 'target_id is null';
|
||||
when new.auth_token_id is null then
|
||||
raise exception 'auth_token_id is null';
|
||||
when new.project_id is null then
|
||||
raise exception 'project_id is null';
|
||||
when new.endpoint is null then
|
||||
raise exception 'endpoint is null';
|
||||
else
|
||||
end case;
|
||||
return new;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
create trigger insert_session before insert on session
|
||||
for each row execute procedure insert_session();
|
||||
|
||||
-- Replaces view from 59/01_target_ingress_egress_worker_filters.up.sql
|
||||
create view session_list as
|
||||
select
|
||||
s.public_id,
|
||||
s.user_id,
|
||||
shsh.host_id,
|
||||
s.target_id,
|
||||
shsh.host_set_id,
|
||||
s.auth_token_id,
|
||||
s.project_id,
|
||||
s.certificate,
|
||||
s.certificate_private_key,
|
||||
s.expiration_time,
|
||||
s.connection_limit,
|
||||
s.tofu_token,
|
||||
s.key_id,
|
||||
s.termination_reason,
|
||||
s.version,
|
||||
s.create_time,
|
||||
s.update_time,
|
||||
s.endpoint,
|
||||
s.worker_filter,
|
||||
s.egress_worker_filter,
|
||||
s.ingress_worker_filter,
|
||||
ss.state,
|
||||
ss.previous_end_time,
|
||||
ss.start_time,
|
||||
ss.end_time,
|
||||
sc.public_id as connection_id,
|
||||
sc.client_tcp_address,
|
||||
sc.client_tcp_port,
|
||||
sc.endpoint_tcp_address,
|
||||
sc.endpoint_tcp_port,
|
||||
sc.bytes_up,
|
||||
sc.bytes_down,
|
||||
sc.closed_reason
|
||||
from session s
|
||||
join session_state ss on
|
||||
s.public_id = ss.session_id
|
||||
left join session_connection sc on
|
||||
s.public_id = sc.session_id
|
||||
left join session_host_set_host shsh on s.public_id = shsh.session_id;
|
||||
|
||||
commit;
|
||||
@@ -0,0 +1,424 @@
|
||||
begin;
|
||||
|
||||
-- replaced view in 44/03_targets.up.sql
|
||||
drop view whx_host_dimension_source;
|
||||
create view whx_host_dimension_source as
|
||||
with
|
||||
host_sources (
|
||||
host_id, host_type, host_name, host_description,
|
||||
host_set_id, host_set_type, host_set_name, host_set_description,
|
||||
host_catalog_id, host_catalog_type, host_catalog_name, host_catalog_description,
|
||||
target_id, target_type, target_name, target_description,
|
||||
target_default_port_number, target_session_max_seconds, target_session_connection_limit,
|
||||
project_id, project_name, project_description,
|
||||
organization_id, organization_name, organization_description
|
||||
) as (
|
||||
select
|
||||
h.public_id as host_id,
|
||||
case when sh.public_id is not null then 'static host'
|
||||
when ph.public_id is not null then 'plugin host'
|
||||
else 'Unknown' end as host_type,
|
||||
case when sh.public_id is not null then coalesce(sh.name, 'None')
|
||||
when ph.public_id is not null then coalesce(ph.name, 'None')
|
||||
else 'Unknown' end as host_name,
|
||||
case when sh.public_id is not null then coalesce(sh.description, 'None')
|
||||
when ph.public_id is not null then coalesce(ph.description, 'None')
|
||||
else 'Unknown' end as host_description,
|
||||
hs.public_id as host_set_id,
|
||||
case when shs.public_id is not null then 'static host set'
|
||||
when phs.public_id is not null then 'plugin host set'
|
||||
else 'Unknown' end as host_set_type,
|
||||
case
|
||||
when shs.public_id is not null then coalesce(shs.name, 'None')
|
||||
when phs.public_id is not null then coalesce(phs.name, 'None')
|
||||
else 'None'
|
||||
end as host_set_name,
|
||||
case
|
||||
when shs.public_id is not null then coalesce(shs.description, 'None')
|
||||
when phs.public_id is not null then coalesce(phs.description, 'None')
|
||||
else 'None'
|
||||
end as host_set_description,
|
||||
hc.public_id as host_catalog_id,
|
||||
case when shc.public_id is not null then 'static host catalog'
|
||||
when phc.public_id is not null then 'plugin host catalog'
|
||||
else 'Unknown' end as host_catalog_type,
|
||||
case
|
||||
when shc.public_id is not null then coalesce(shc.name, 'None')
|
||||
when phc.public_id is not null then coalesce(phc.name, 'None')
|
||||
else 'None'
|
||||
end as host_catalog_name,
|
||||
case
|
||||
when shc.public_id is not null then coalesce(shc.description, 'None')
|
||||
when phc.public_id is not null then coalesce(phc.description, 'None')
|
||||
else 'None'
|
||||
end as host_catalog_description,
|
||||
t.public_id as target_id,
|
||||
'tcp target' as target_type,
|
||||
coalesce(t.name, 'None') as target_name,
|
||||
coalesce(t.description, 'None') as target_description,
|
||||
coalesce(t.default_port, 0) as target_default_port_number,
|
||||
t.session_max_seconds as target_session_max_seconds,
|
||||
t.session_connection_limit as target_session_connection_limit,
|
||||
p.public_id as project_id,
|
||||
coalesce(p.name, 'None') as project_name,
|
||||
coalesce(p.description, 'None') as project_description,
|
||||
o.public_id as organization_id,
|
||||
coalesce(o.name, 'None') as organization_name,
|
||||
coalesce(o.description, 'None') as organization_description
|
||||
from host as h
|
||||
join host_catalog as hc on h.catalog_id = hc.public_id
|
||||
join host_set as hs on h.catalog_id = hs.catalog_id
|
||||
join target_host_set as ts on hs.public_id = ts.host_set_id
|
||||
join target_tcp as t on ts.target_id = t.public_id
|
||||
join iam_scope as p on t.project_id = p.public_id and p.type = 'project'
|
||||
join iam_scope as o on p.parent_id = o.public_id and o.type = 'org'
|
||||
|
||||
left join static_host as sh on sh.public_id = h.public_id
|
||||
left join host_plugin_host as ph on ph.public_id = h.public_id
|
||||
left join static_host_catalog as shc on shc.public_id = hc.public_id
|
||||
left join host_plugin_catalog as phc on phc.public_id = hc.public_id
|
||||
left join static_host_set as shs on shs.public_id = hs.public_id
|
||||
left join host_plugin_set as phs on phs.public_id = hs.public_id
|
||||
),
|
||||
host_target_address (
|
||||
host_id, host_type, host_name, host_description,
|
||||
host_set_id, host_set_type, host_set_name, host_set_description,
|
||||
host_catalog_id, host_catalog_type, host_catalog_name, host_catalog_description,
|
||||
target_id, target_type, target_name, target_description,
|
||||
target_default_port_number, target_session_max_seconds, target_session_connection_limit,
|
||||
project_id, project_name, project_description,
|
||||
organization_id, organization_name, organization_description
|
||||
) as (
|
||||
select
|
||||
'Not Applicable' as host_id,
|
||||
'direct address' as host_type,
|
||||
'Not Applicable' as host_name,
|
||||
'Not Applicable' as host_description,
|
||||
'Not Applicable' as host_set_id,
|
||||
'Not Applicable' as host_set_type,
|
||||
'Not Applicable' as host_set_name,
|
||||
'Not Applicable' as host_set_description,
|
||||
'Not Applicable' as host_catalog_id,
|
||||
'Not Applicable' as host_catalog_type,
|
||||
'Not Applicable' as host_catalog_name,
|
||||
'Not Applicable' as host_catalog_description,
|
||||
t.public_id as target_id,
|
||||
'tcp target' as target_type,
|
||||
coalesce(t.name, 'None') as target_name,
|
||||
coalesce(t.description, 'None') as target_description,
|
||||
coalesce(t.default_port, 0) as target_default_port_number,
|
||||
t.session_max_seconds as target_session_max_seconds,
|
||||
t.session_connection_limit as target_session_connection_limit,
|
||||
p.public_id as project_id,
|
||||
coalesce(p.name, 'None') as project_name,
|
||||
coalesce(p.description, 'None') as project_description,
|
||||
o.public_id as organization_id,
|
||||
coalesce(o.name, 'None') as organization_name,
|
||||
coalesce(o.description, 'None') as organization_description
|
||||
from target_tcp as t
|
||||
right join target_address as ta on t.public_id = ta.target_id
|
||||
left join iam_scope as p on p.public_id = t.project_id
|
||||
left join iam_scope as o on o.public_id = p.parent_id
|
||||
)
|
||||
select * from host_sources
|
||||
union
|
||||
select * from host_target_address;
|
||||
|
||||
-- replaced function in 26/03_wh_network_address_dimensions.up.sql
|
||||
create or replace function wh_upsert_host() returns trigger
|
||||
as $$
|
||||
declare
|
||||
p_target_id wt_public_id;
|
||||
p_host_key wh_dim_key;
|
||||
src whx_host_dimension_target%rowtype;
|
||||
target whx_host_dimension_target%rowtype;
|
||||
addr_group_key wh_dim_key;
|
||||
begin
|
||||
select target_id into p_target_id
|
||||
from session
|
||||
where session.public_id = new.session_id;
|
||||
|
||||
if p_target_id is null then
|
||||
raise exception 'target_id is null';
|
||||
end if;
|
||||
|
||||
select * into target
|
||||
from whx_host_dimension_target as t
|
||||
where t.host_id = new.host_id
|
||||
and t.host_set_id = new.host_set_id
|
||||
and t.target_id = p_target_id;
|
||||
|
||||
select wh_upsert_network_address_dimension(new.host_id) into addr_group_key;
|
||||
|
||||
select target.key, addr_group_key, t.* into src
|
||||
from whx_host_dimension_source as t
|
||||
where t.host_id = new.host_id
|
||||
and t.host_set_id = new.host_set_id
|
||||
and t.target_id = p_target_id;
|
||||
|
||||
if src is distinct from target then
|
||||
|
||||
-- expire the current row
|
||||
update wh_host_dimension
|
||||
set current_row_indicator = 'Expired',
|
||||
row_expiration_time = current_timestamp
|
||||
where host_id = new.host_id
|
||||
and host_set_id = new.host_set_id
|
||||
and target_id = p_target_id
|
||||
and current_row_indicator = 'Current';
|
||||
|
||||
-- insert a new row
|
||||
insert into wh_host_dimension (
|
||||
host_id, host_type, host_name, host_description,
|
||||
network_address_group_key,
|
||||
host_set_id, host_set_type, host_set_name, host_set_description,
|
||||
host_catalog_id, host_catalog_type, host_catalog_name, host_catalog_description,
|
||||
target_id, target_type, target_name, target_description,
|
||||
target_default_port_number, target_session_max_seconds, target_session_connection_limit,
|
||||
project_id, project_name, project_description,
|
||||
organization_id, organization_name, organization_description,
|
||||
current_row_indicator, row_effective_time, row_expiration_time
|
||||
)
|
||||
select host_id, host_type, host_name, host_description,
|
||||
addr_group_key,
|
||||
host_set_id, host_set_type, host_set_name, host_set_description,
|
||||
host_catalog_id, host_catalog_type, host_catalog_name, host_catalog_description,
|
||||
target_id, target_type, target_name, target_description,
|
||||
target_default_port_number, target_session_max_seconds, target_session_connection_limit,
|
||||
project_id, project_name, project_description,
|
||||
organization_id, organization_name, organization_description,
|
||||
'Current', current_timestamp, 'infinity'::timestamptz
|
||||
from whx_host_dimension_source
|
||||
where host_id = new.host_id
|
||||
and host_set_id = new.host_set_id
|
||||
and target_id = p_target_id;
|
||||
|
||||
end if;
|
||||
|
||||
select key into p_host_key
|
||||
from wh_host_dimension as t
|
||||
where t.current_row_indicator = 'Current'
|
||||
and t.host_id = new.host_id
|
||||
and t.host_set_id = new.host_set_id
|
||||
and t.target_id = p_target_id;
|
||||
|
||||
update wh_session_accumulating_fact
|
||||
set host_key = p_host_key
|
||||
where session_id = new.session_id;
|
||||
|
||||
return new;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
create trigger wh_update_session_connection_accumulating_fact after insert on session_host_set_host
|
||||
for each row execute procedure wh_upsert_host();
|
||||
|
||||
-- replaced function in 16/04_wh_credential_dimension.up.sql
|
||||
create or replace function wh_insert_session() returns trigger
|
||||
as $$
|
||||
declare
|
||||
new_row wh_session_accumulating_fact%rowtype;
|
||||
begin
|
||||
with
|
||||
pending_timestamp (date_dim_key, time_dim_key, ts) as (
|
||||
select wh_date_key(start_time), wh_time_key(start_time), start_time
|
||||
from session_state
|
||||
where session_id = new.public_id
|
||||
and state = 'pending'
|
||||
)
|
||||
insert into wh_session_accumulating_fact (
|
||||
session_id,
|
||||
auth_token_id,
|
||||
host_key,
|
||||
user_key,
|
||||
credential_group_key,
|
||||
session_pending_date_key,
|
||||
session_pending_time_key,
|
||||
session_pending_time
|
||||
)
|
||||
select new.public_id,
|
||||
new.auth_token_id,
|
||||
'no host source', -- will be updated by wh_upsert_host
|
||||
wh_upsert_user(new.user_id, new.auth_token_id),
|
||||
'no credentials', -- will be updated by wh_upsert_credential_group
|
||||
pending_timestamp.date_dim_key,
|
||||
pending_timestamp.time_dim_key,
|
||||
pending_timestamp.ts
|
||||
from pending_timestamp
|
||||
returning * into strict new_row;
|
||||
return null;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
insert into wh_host_dimension (
|
||||
key,
|
||||
host_id, host_type, host_name, host_description,
|
||||
host_set_id, host_set_type, host_set_name, host_set_description,
|
||||
host_catalog_id, host_catalog_type, host_catalog_name, host_catalog_description,
|
||||
target_id, target_type, target_name, target_description, target_default_port_number, target_session_max_seconds, target_session_connection_limit,
|
||||
project_id, project_name, project_description, organization_id, organization_name, organization_description,
|
||||
current_row_indicator, row_effective_time, row_expiration_time, network_address_group_key
|
||||
)
|
||||
values
|
||||
(
|
||||
'no host source',
|
||||
'None', 'None', 'None', 'None',
|
||||
'None', 'None', 'None', 'None',
|
||||
'None', 'None', 'None', 'None',
|
||||
'None', 'None', 'None', 'None', -1, -1, -1,
|
||||
'00000000000', 'None', 'None', '00000000000', 'None', 'None',
|
||||
'Current', now(), 'infinity'::timestamptz, 'Unknown'
|
||||
);
|
||||
|
||||
create function wh_upsert_direct_network_address_dimension(p_address text, p_target_id text) returns wh_dim_key
|
||||
as $$
|
||||
declare
|
||||
p_address_type text := 'Not Applicable';
|
||||
p_ip_address_family text := 'Not Applicable';
|
||||
p_private_ip_address_indicator text := 'Not Applicable';
|
||||
p_dns_name text := 'Not Applicable';
|
||||
p_ip4_address text := 'Not Applicable';
|
||||
p_ip6_address text := 'Not Applicable';
|
||||
nag_key wh_dim_key;
|
||||
begin
|
||||
if wh_try_cast_inet(p_address) is null then
|
||||
p_address_type := 'DNS Name';
|
||||
p_dns_name := p_address;
|
||||
else
|
||||
p_address_type := 'IP Address';
|
||||
p_private_ip_address_indicator := wh_private_address_indicator(wh_try_cast_inet(p_address));
|
||||
end if;
|
||||
|
||||
if family(wh_try_cast_inet(p_address)) = 4 then
|
||||
p_ip_address_family := 'IPv4';
|
||||
p_ip4_address := host(wh_try_cast_inet(p_address));
|
||||
elsif family(wh_try_cast_inet(p_address)) = 6 then
|
||||
p_ip_address_family := 'IPv6';
|
||||
p_ip6_address := host(wh_try_cast_inet(p_address));
|
||||
end if;
|
||||
|
||||
insert into wh_network_address_dimension
|
||||
(address, address_type, ip_address_family, private_ip_address_indicator, dns_name, ip4_address, ip6_address)
|
||||
values
|
||||
(p_address, p_address_type, p_ip_address_family, p_private_ip_address_indicator, p_dns_name, p_ip4_address, p_ip6_address) on conflict do nothing;
|
||||
|
||||
select distinct g.network_address_group_key into nag_key
|
||||
from wh_network_address_group_membership g
|
||||
left join wh_host_dimension h on g.network_address_group_key = h.network_address_group_key
|
||||
where g.network_address = p_address
|
||||
and h.current_row_indicator = 'Current'
|
||||
and h.target_id = p_target_id
|
||||
and h.host_id = 'Not Applicable'
|
||||
and h.host_set_id = 'Not Applicable';
|
||||
|
||||
if nag_key is null then
|
||||
select network_address_group_key into nag_key
|
||||
from wh_host_dimension h
|
||||
where h.current_row_indicator = 'Current'
|
||||
and h.host_id = 'Not Applicable'
|
||||
and h.host_set_id = 'Not Applicable'
|
||||
and h.target_id = p_target_id;
|
||||
end if;
|
||||
|
||||
if nag_key is null then
|
||||
insert into wh_network_address_group default values returning key into nag_key;
|
||||
end if;
|
||||
|
||||
insert into wh_network_address_group_membership
|
||||
(network_address_group_key, network_address)
|
||||
values
|
||||
(nag_key, p_address) on conflict do nothing;
|
||||
|
||||
return nag_key;
|
||||
end
|
||||
$$ language plpgsql;
|
||||
|
||||
create function wh_upsert_host_direct_network_address() returns trigger
|
||||
as $$
|
||||
declare
|
||||
p_address text;
|
||||
src whx_host_dimension_target%rowtype;
|
||||
target whx_host_dimension_target%rowtype;
|
||||
addr_group_key wh_dim_key;
|
||||
p_host_key wh_dim_key;
|
||||
begin
|
||||
select address into p_address
|
||||
from target_address
|
||||
where target_address.target_id = new.target_id;
|
||||
|
||||
if p_address is null then
|
||||
raise exception 'target address is null';
|
||||
end if;
|
||||
|
||||
select * into target
|
||||
from whx_host_dimension_target as t
|
||||
where t.host_id = 'Not Applicable'
|
||||
and t.host_set_id = 'Not Applicable'
|
||||
and t.target_id = new.target_id;
|
||||
|
||||
select wh_upsert_direct_network_address_dimension(p_address, new.target_id) into addr_group_key;
|
||||
|
||||
select target.key, addr_group_key, t.* into src
|
||||
from whx_host_dimension_source as t
|
||||
where t.host_id = 'Not Applicable'
|
||||
and t.host_set_id = 'Not Applicable'
|
||||
and t.target_id = new.target_id;
|
||||
|
||||
if src is distinct from target then
|
||||
|
||||
-- expire the current row
|
||||
update wh_host_dimension
|
||||
set current_row_indicator = 'Expired',
|
||||
row_expiration_time = current_timestamp
|
||||
where host_id = 'Not Applicable'
|
||||
and host_set_id = 'Not Applicable'
|
||||
and target_id = new.target_id
|
||||
and current_row_indicator = 'Current';
|
||||
|
||||
-- insert a new row
|
||||
insert into wh_host_dimension (
|
||||
host_id, host_type, host_name, host_description,
|
||||
network_address_group_key,
|
||||
host_set_id, host_set_type, host_set_name, host_set_description,
|
||||
host_catalog_id, host_catalog_type, host_catalog_name, host_catalog_description,
|
||||
target_id, target_type, target_name, target_description,
|
||||
target_default_port_number, target_session_max_seconds, target_session_connection_limit,
|
||||
project_id, project_name, project_description,
|
||||
organization_id, organization_name, organization_description,
|
||||
current_row_indicator, row_effective_time, row_expiration_time
|
||||
)
|
||||
select host_id, host_type, host_name, host_description,
|
||||
addr_group_key,
|
||||
host_set_id, host_set_type, host_set_name, host_set_description,
|
||||
host_catalog_id, host_catalog_type, host_catalog_name, host_catalog_description,
|
||||
target_id, target_type, target_name, target_description,
|
||||
target_default_port_number, target_session_max_seconds, target_session_connection_limit,
|
||||
project_id, project_name, project_description,
|
||||
organization_id, organization_name, organization_description,
|
||||
'Current', current_timestamp, 'infinity'::timestamptz
|
||||
from whx_host_dimension_source
|
||||
where host_id = 'Not Applicable'
|
||||
and host_set_id = 'Not Applicable'
|
||||
and target_id = new.target_id;
|
||||
|
||||
end if;
|
||||
|
||||
select key into p_host_key
|
||||
from wh_host_dimension as t
|
||||
where t.current_row_indicator = 'Current'
|
||||
and t.host_id = 'Not Applicable'
|
||||
and t.host_set_id = 'Not Applicable'
|
||||
and t.target_id = new.target_id;
|
||||
|
||||
update wh_session_accumulating_fact
|
||||
set host_key = p_host_key
|
||||
where session_id = new.session_id;
|
||||
|
||||
return new;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
create trigger wh_update_session_connection_accumulating_fact after insert on session_target_address
|
||||
for each row execute procedure wh_upsert_host_direct_network_address();
|
||||
|
||||
commit;
|
||||
@@ -10,7 +10,8 @@ begin;
|
||||
(parent_id, type, public_id, name)
|
||||
values
|
||||
('o_____colors', 'project', 'p____bcolors', 'Blue Color Mill'),
|
||||
('o_____colors', 'project', 'p____rcolors', 'Red Color Mill');
|
||||
('o_____colors', 'project', 'p____rcolors', 'Red Color Mill'),
|
||||
('o_____colors', 'project', 'p____gcolors', 'Green Color Mill');
|
||||
|
||||
-- Add global users
|
||||
insert into iam_user
|
||||
@@ -27,7 +28,8 @@ begin;
|
||||
('o_____colors', 'u______clare', 'Clare'),
|
||||
('o_____colors', 'u______cindy', 'Cindy'),
|
||||
('o_____colors', 'u______carly', 'Carly'),
|
||||
('o_____colors', 'u______ciara', 'Ciara');
|
||||
('o_____colors', 'u______ciara', 'Ciara'),
|
||||
('o_____colors', 'u_______cora', 'Cora');
|
||||
|
||||
-- Add keys
|
||||
insert into kms_root_key
|
||||
@@ -56,7 +58,8 @@ begin;
|
||||
('global', 'g___gg-group', 'Global Group'),
|
||||
('o_____colors', 'g___oc-group', 'Colors R Us Group'),
|
||||
('p____bcolors', 'g___cb-group', 'Blue Color Group'),
|
||||
('p____rcolors', 'g___cr-group', 'Red Color Group');
|
||||
('p____rcolors', 'g___cr-group', 'Red Color Group'),
|
||||
('p____gcolors', 'g___cg-group', 'Green Color Group');
|
||||
|
||||
insert into iam_group_member_user
|
||||
(group_id, member_id)
|
||||
@@ -64,15 +67,18 @@ begin;
|
||||
('g___gg-group', 'u_______gary'),
|
||||
('g___oc-group', 'u______clare'),
|
||||
('g___cb-group', 'u______cindy'),
|
||||
('g___cr-group', 'u______carly');
|
||||
('g___cr-group', 'u______carly'),
|
||||
('g___cg-group', 'u_______cora');
|
||||
|
||||
insert into iam_role
|
||||
(scope_id, grant_scope_id, public_id, name)
|
||||
values
|
||||
('p____bcolors', 'p____bcolors', 'r_pp_bc__mix', 'Color Mixer'),
|
||||
('p____rcolors', 'p____rcolors', 'r_pp_rc__mix', 'Color Mixer'),
|
||||
('p____gcolors', 'p____gcolors', 'r_pp_gc__mix', 'Color Mixer'),
|
||||
('o_____colors', 'p____bcolors', 'r_op_bc__art', 'Blue Color Artist'),
|
||||
('o_____colors', 'p____rcolors', 'r_op_rc__art', 'Red Color Artist'),
|
||||
('o_____colors', 'p____gcolors', 'r_op_gc__art', 'Green Color Artist'),
|
||||
('o_____colors', 'o_____colors', 'r_oo_____art', 'Color Artist'),
|
||||
('global', 'o_____colors', 'r_go____name', 'Color Namer'),
|
||||
('global', 'p____bcolors', 'r_gp____spec', 'Blue Color Inspector'),
|
||||
@@ -89,15 +95,18 @@ begin;
|
||||
('r_oo_____art', 'type=color;action=create', 'create color'),
|
||||
('r_op_bc__art', 'type=color;action=create', 'create color'),
|
||||
('r_op_rc__art', 'type=color;action=create', 'create color'),
|
||||
('r_op_gc__art', 'type=color;action=create', 'create color'),
|
||||
('r_pp_bc__mix', 'type=color;action=mix', 'mix color'),
|
||||
('r_pp_rc__mix', 'type=color;action=mix', 'mix color');
|
||||
('r_pp_rc__mix', 'type=color;action=mix', 'mix color'),
|
||||
('r_pp_gc__mix', 'type=color;action=mix', 'mix color');
|
||||
|
||||
insert into iam_group_role
|
||||
(role_id, principal_id)
|
||||
values
|
||||
('r_op_rc__art', 'g___oc-group'), -- color
|
||||
('r_pp_bc__mix', 'g___cb-group'), -- color
|
||||
('r_pp_rc__mix', 'g___cr-group'); -- color
|
||||
('r_pp_rc__mix', 'g___cr-group'), -- color
|
||||
('r_pp_gc__mix', 'g___cg-group'); -- color
|
||||
|
||||
insert into iam_user_role
|
||||
(role_id, principal_id)
|
||||
@@ -125,18 +134,21 @@ begin;
|
||||
('apm___colors', 'apa____clare', 'clare'),
|
||||
('apm___colors', 'apa____cindy', 'cindy'),
|
||||
('apm___colors', 'apa____carly', 'carly'),
|
||||
('apm___colors', 'apa_____cora', 'cora'),
|
||||
('apm___colors', 'apa____ciara', 'ciara');
|
||||
|
||||
update auth_account set iam_user_id = 'u______clare' where public_id = 'apa____clare';
|
||||
update auth_account set iam_user_id = 'u______cindy' where public_id = 'apa____cindy';
|
||||
update auth_account set iam_user_id = 'u______carly' where public_id = 'apa____carly';
|
||||
update auth_account set iam_user_id = 'u_______cora' where public_id = 'apa_____cora';
|
||||
update auth_account set iam_user_id = 'u______ciara' where public_id = 'apa____ciara';
|
||||
|
||||
insert into static_host_catalog
|
||||
(project_id, public_id, name)
|
||||
values
|
||||
('p____bcolors', 'c___cb-sthcl', 'Blue Color Static Catalog'),
|
||||
('p____rcolors', 'c___cr-sthcl', 'Red Color Static Catalog');
|
||||
('p____rcolors', 'c___cr-sthcl', 'Red Color Static Catalog'),
|
||||
('p____gcolors', 'c___cg-sthcl', 'Green Color Static Catalog');
|
||||
|
||||
insert into auth_token
|
||||
(key_id, auth_account_id, public_id, token)
|
||||
@@ -144,7 +156,8 @@ begin;
|
||||
('kdkv_______colors', 'apa____clare', 'tok____clare', 'tok____clare'::bytea),
|
||||
('kdkv_______colors', 'apa____cindy', 'tok____cindy', 'tok____cindy'::bytea),
|
||||
('kdkv_______colors', 'apa____ciara', 'tok____ciara', 'tok____ciara'::bytea),
|
||||
('kdkv_______colors', 'apa____carly', 'tok____carly', 'tok____carly'::bytea);
|
||||
('kdkv_______colors', 'apa____carly', 'tok____carly', 'tok____carly'::bytea),
|
||||
('kdkv_______colors', 'apa_____cora', 'tok_____cora', 'tok_____cora'::bytea);
|
||||
|
||||
insert into static_host
|
||||
(catalog_id, public_id, address)
|
||||
@@ -167,7 +180,17 @@ begin;
|
||||
('c___cr-sthcl', 'h_____cr__06', '6.red.color'),
|
||||
('c___cr-sthcl', 'h_____cr__07', '7.red.color'),
|
||||
('c___cr-sthcl', 'h_____cr__08', '8.red.color'),
|
||||
('c___cr-sthcl', 'h_____cr__09', '9.red.color');
|
||||
('c___cr-sthcl', 'h_____cr__09', '9.red.color'),
|
||||
|
||||
('c___cg-sthcl', 'h_____cg__01', '1.green.color'),
|
||||
('c___cg-sthcl', 'h_____cg__02', '2.green.color'),
|
||||
('c___cg-sthcl', 'h_____cg__03', '3.green.color'),
|
||||
('c___cg-sthcl', 'h_____cg__04', '4.green.color'),
|
||||
('c___cg-sthcl', 'h_____cg__05', '5.green.color'),
|
||||
('c___cg-sthcl', 'h_____cg__06', '6.green.color'),
|
||||
('c___cg-sthcl', 'h_____cg__07', '7.green.color'),
|
||||
('c___cg-sthcl', 'h_____cg__08', '8.green.color'),
|
||||
('c___cg-sthcl', 'h_____cg__09', '9.green.color');
|
||||
|
||||
insert into host_dns_name
|
||||
(host_id, name)
|
||||
@@ -190,7 +213,17 @@ begin;
|
||||
('h_____cr__06', '6.red.color'),
|
||||
('h_____cr__07', '7.red.color'),
|
||||
('h_____cr__08', '8.red.color'),
|
||||
('h_____cr__09', '9.red.color');
|
||||
('h_____cr__09', '9.red.color'),
|
||||
|
||||
('h_____cg__01', '1.green.color'),
|
||||
('h_____cg__02', '2.green.color'),
|
||||
('h_____cg__03', '3.green.color'),
|
||||
('h_____cg__04', '4.green.color'),
|
||||
('h_____cg__05', '5.green.color'),
|
||||
('h_____cg__06', '6.green.color'),
|
||||
('h_____cg__07', '7.green.color'),
|
||||
('h_____cg__08', '8.green.color'),
|
||||
('h_____cg__09', '9.green.color');
|
||||
|
||||
insert into host_ip_address
|
||||
(host_id, address)
|
||||
@@ -213,7 +246,17 @@ begin;
|
||||
('h_____cr__06', '2001:4860:4860::6666'),
|
||||
('h_____cr__07', '77.77.77.77'),
|
||||
('h_____cr__08', '2001:4860:4860::8888'),
|
||||
('h_____cr__09', '99.99.99.99');
|
||||
('h_____cr__09', '99.99.99.99'),
|
||||
|
||||
('h_____cg__01', '111.111.111.111'),
|
||||
('h_____cg__02', '3001:5860:5860::3333'),
|
||||
('h_____cg__03', '112.112.112.112'),
|
||||
('h_____cg__04', '3001:5860:5860::5555'),
|
||||
('h_____cg__05', '113.113.113.113'),
|
||||
('h_____cg__06', '3001:5860:5860::7777'),
|
||||
('h_____cg__07', '114.114.114.114'),
|
||||
('h_____cg__08', '3001:5860:5860::9999'),
|
||||
('h_____cg__09', '115.115.115.115');
|
||||
|
||||
insert into static_host_set
|
||||
(catalog_id, public_id, name)
|
||||
@@ -221,7 +264,9 @@ begin;
|
||||
('c___cb-sthcl', 's___1cb-sths', 'Blue Color Static Set 1'),
|
||||
('c___cb-sthcl', 's___2cb-sths', 'Blue Color Static Set 2'),
|
||||
('c___cr-sthcl', 's___1cr-sths', 'Red Color Static Set 1'),
|
||||
('c___cr-sthcl', 's___2cr-sths', 'Red Color Static Set 2');
|
||||
('c___cr-sthcl', 's___2cr-sths', 'Red Color Static Set 2'),
|
||||
('c___cg-sthcl', 's___1cg-sths', 'Green Color Static Set 1'),
|
||||
('c___cg-sthcl', 's___2cg-sths', 'Green Color Static Set 2');
|
||||
|
||||
insert
|
||||
into static_host_set_member
|
||||
@@ -235,7 +280,8 @@ begin;
|
||||
(project_id, public_id, name)
|
||||
values
|
||||
('p____bcolors', 't_________cb', 'Blue Color Target'),
|
||||
('p____rcolors', 't_________cr', 'Red Color Target');
|
||||
('p____rcolors', 't_________cr', 'Red Color Target'),
|
||||
('p____gcolors', 't_________cg', 'Green Color Target');
|
||||
|
||||
insert into target_host_set
|
||||
(project_id, target_id, host_set_id)
|
||||
@@ -245,6 +291,11 @@ begin;
|
||||
('p____rcolors', 't_________cr', 's___1cr-sths'),
|
||||
('p____rcolors', 't_________cr', 's___2cr-sths');
|
||||
|
||||
insert into target_address
|
||||
(target_id, address)
|
||||
values
|
||||
('t_________cg', '8.8.8.8');
|
||||
|
||||
insert into credential_vault_store
|
||||
(project_id, public_id, name, description, vault_address, namespace)
|
||||
values
|
||||
@@ -263,12 +314,26 @@ begin;
|
||||
('p____bcolors', 't_________cb', 'vl______cvl', 'brokered');
|
||||
|
||||
insert into session
|
||||
( project_id, target_id, host_set_id, host_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
( project_id, target_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
values
|
||||
('p____bcolors', 't_________cb', 's___1cb-sths', 'h_____cb__01', 'u______clare', 'tok____clare', 'abc'::bytea, 'ep1', 's1_____clare'),
|
||||
('p____bcolors', 't_________cb', 's___1cb-sths', 'h_____cb__01', 'u______cindy', 'tok____cindy', 'abc'::bytea, 'ep1', 's1_____cindy'),
|
||||
('p____bcolors', 't_________cb', 's___1cb-sths', 'h_____cb__01', 'u______cindy', 'tok____cindy', 'abc'::bytea, 'ep1', 's1_____ciara'),
|
||||
('p____bcolors', 't_________cb', 's___1cb-sths', 'h_____cb__01', 'u______carly', 'tok____carly', 'abc'::bytea, 'ep1', 's1_____carly');
|
||||
('p____bcolors', 't_________cb', 'u______clare', 'tok____clare', 'abc'::bytea, 'ep1', 's1_____clare'),
|
||||
('p____bcolors', 't_________cb', 'u______cindy', 'tok____cindy', 'abc'::bytea, 'ep1', 's1_____cindy'),
|
||||
('p____bcolors', 't_________cb', 'u______cindy', 'tok____cindy', 'abc'::bytea, 'ep1', 's1_____ciara'),
|
||||
('p____bcolors', 't_________cb', 'u______carly', 'tok____carly', 'abc'::bytea, 'ep1', 's1_____carly'),
|
||||
('p____gcolors', 't_________cg', 'u_______cora', 'tok_____cora', 'abc'::bytea, 'ep1', 's1______cora');
|
||||
|
||||
insert into session_host_set_host
|
||||
(session_id, host_set_id, host_id)
|
||||
values
|
||||
('s1_____clare', 's___1cb-sths', 'h_____cb__01'),
|
||||
('s1_____cindy', 's___1cb-sths', 'h_____cb__01'),
|
||||
('s1_____ciara', 's___1cb-sths', 'h_____cb__01'),
|
||||
('s1_____carly', 's___1cb-sths', 'h_____cb__01');
|
||||
|
||||
insert into session_target_address
|
||||
(session_id, target_id)
|
||||
values
|
||||
('s1______cora', 't_________cg');
|
||||
|
||||
insert into session_connection
|
||||
(session_id, public_id)
|
||||
|
||||
@@ -122,8 +122,13 @@ begin;
|
||||
('r_pp___tacos', 'u________bob');
|
||||
|
||||
insert into session
|
||||
( project_id, target_id, host_set_id, host_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
( project_id, target_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
values
|
||||
('p______tacos', 't__________t', 's____1t-sths', 'h______t__01', 'u________jim', 'tok______jim', 'abc'::bytea, 'ep1', 's1_______jim');
|
||||
('p______tacos', 't__________t', 'u________jim', 'tok______jim', 'abc'::bytea, 'ep1', 's1_______jim');
|
||||
|
||||
insert into session_host_set_host
|
||||
(session_id, host_set_id, host_id)
|
||||
values
|
||||
('s1_______jim', 's____1t-sths', 'h______t__01');
|
||||
|
||||
commit;
|
||||
@@ -0,0 +1,28 @@
|
||||
begin;
|
||||
select plan(12);
|
||||
|
||||
-- Ensure session state table is populated
|
||||
select is(count(*), 1::bigint) from session_state where session_id = 's1_____clare' and state='pending';
|
||||
select is(count(*), 1::bigint) from session_state where session_id = 's1_____cindy' and state='terminated';
|
||||
select is(count(*), 1::bigint) from session_state where session_id = 's1_____ciara' and state='canceling';
|
||||
select is(count(*), 1::bigint) from session_state where session_id = 's1_____carly' and state='active';
|
||||
|
||||
-- Check that we have a session for both auth token
|
||||
select is(count(*), 1::bigint) from session where auth_token_id = 'tok____clare';
|
||||
select is(count(*), 1::bigint) from session where auth_token_id = 'tok____carly';
|
||||
|
||||
-- Delete auth tokens, expect no errors
|
||||
delete from auth_token where public_id = 'tok____clare' or public_id = 'tok____carly';
|
||||
select is(count(*), 0::bigint) from auth_token where public_id = 'tok____clare';
|
||||
select is(count(*), 0::bigint) from auth_token where public_id = 'tok____carly';
|
||||
|
||||
-- Ensure we no longer have sessions associated with auth tokens
|
||||
select is(count(*), 0::bigint) from session where auth_token_id = 'tok____clare';
|
||||
select is(count(*), 0::bigint) from session where auth_token_id = 'tok____carly';
|
||||
|
||||
-- Ensure sessions that were pending or active are now in canceling state
|
||||
select is(count(*), 1::bigint) from session_state where state = 'canceling' and session_id = 's1_____clare';
|
||||
select is(count(*), 1::bigint) from session_state where state = 'canceling' and session_id = 's1_____carly';
|
||||
|
||||
select * from finish();
|
||||
rollback;
|
||||
@@ -0,0 +1,25 @@
|
||||
begin;
|
||||
select plan(9);
|
||||
|
||||
-- Ensure session state table is populated
|
||||
select is(count(*), 1::bigint) from session_state where session_id = 's1_____clare' and state='pending';
|
||||
select is(count(*), 1::bigint) from session_state where session_id = 's1_____cindy' and state='terminated';
|
||||
select is(count(*), 1::bigint) from session_state where session_id = 's1_____ciara' and state='canceling';
|
||||
select is(count(*), 1::bigint) from session_state where session_id = 's1_____carly' and state='active';
|
||||
|
||||
-- Check that we have 4 sessions using this host
|
||||
select is(count(*), 4::bigint) from session_host_set_host where host_id = 'h_____cb__01';
|
||||
|
||||
-- Delete host, expect no errors
|
||||
delete from host where public_id = 'h_____cb__01';
|
||||
select is(count(*), 0::bigint) from host where public_id = 'h_____cb__01';
|
||||
|
||||
-- Ensure we no longer have sessions associated with this host
|
||||
select is(count(*), 0::bigint) from session_host_set_host where host_id = 'h_____cb__01';
|
||||
|
||||
-- Ensure sessions that were pending or active are now in canceling state
|
||||
select is(count(*), 1::bigint) from session_state where state = 'canceling' and session_id = 's1_____clare';
|
||||
select is(count(*), 1::bigint) from session_state where state = 'canceling' and session_id = 's1_____carly';
|
||||
|
||||
select * from finish();
|
||||
rollback;
|
||||
@@ -0,0 +1,25 @@
|
||||
begin;
|
||||
select plan(9);
|
||||
|
||||
-- Ensure session state table is populated
|
||||
select is(count(*), 1::bigint) from session_state where session_id = 's1_____clare' and state='pending';
|
||||
select is(count(*), 1::bigint) from session_state where session_id = 's1_____cindy' and state='terminated';
|
||||
select is(count(*), 1::bigint) from session_state where session_id = 's1_____ciara' and state='canceling';
|
||||
select is(count(*), 1::bigint) from session_state where session_id = 's1_____carly' and state='active';
|
||||
|
||||
-- Check that we have 4 sessions using this host set
|
||||
select is(count(*), 4::bigint) from session_host_set_host where host_set_id = 's___1cb-sths';
|
||||
|
||||
-- Delete host set, expect no errors
|
||||
delete from host_set where public_id = 's___1cb-sths';
|
||||
select is(count(*), 0::bigint) from host_set where public_id = 's___1cb-sths';
|
||||
|
||||
-- Ensure we no longer have sessions associated with this host set
|
||||
select is(count(*), 0::bigint) from session_host_set_host where host_set_id = 's___1cb-sths';
|
||||
|
||||
-- Ensure sessions that were pending or active are now in canceling state
|
||||
select is(count(*), 1::bigint) from session_state where state = 'canceling' and session_id = 's1_____clare';
|
||||
select is(count(*), 1::bigint) from session_state where state = 'canceling' and session_id = 's1_____carly';
|
||||
|
||||
select * from finish();
|
||||
rollback;
|
||||
@@ -0,0 +1,25 @@
|
||||
begin;
|
||||
select plan(9);
|
||||
|
||||
-- Ensure session state table is populated
|
||||
select is(count(*), 1::bigint) from session_state where session_id = 's1_____clare' and state='pending';
|
||||
select is(count(*), 1::bigint) from session_state where session_id = 's1_____cindy' and state='terminated';
|
||||
select is(count(*), 1::bigint) from session_state where session_id = 's1_____ciara' and state='canceling';
|
||||
select is(count(*), 1::bigint) from session_state where session_id = 's1_____carly' and state='active';
|
||||
|
||||
-- Check that we have 4 sessions using this project
|
||||
select is(count(*), 4::bigint) from session where project_id = 'p____bcolors';
|
||||
|
||||
-- Delete project, expect no errors
|
||||
delete from iam_scope_project where scope_id = 'p____bcolors';
|
||||
select is(count(*), 0::bigint) from iam_scope_project where scope_id = 'p____bcolors';
|
||||
|
||||
-- Ensure we no longer have sessions associated with this project
|
||||
select is(count(*), 0::bigint) from session where project_id = 'p____bcolors';
|
||||
|
||||
-- Ensure sessions that were pending or active are now in canceling state
|
||||
select is(count(*), 1::bigint) from session_state where state = 'canceling' and session_id = 's1_____clare';
|
||||
select is(count(*), 1::bigint) from session_state where state = 'canceling' and session_id = 's1_____carly';
|
||||
|
||||
select * from finish();
|
||||
rollback;
|
||||
@@ -0,0 +1,25 @@
|
||||
begin;
|
||||
select plan(9);
|
||||
|
||||
-- Ensure session state table is populated
|
||||
select is(count(*), 1::bigint) from session_state where session_id = 's1______cora' and state='pending';
|
||||
select is(count(*), 1::bigint) from session_state where session_id = 's1_____clare' and state='pending';
|
||||
select is(count(*), 1::bigint) from session_state where session_id = 's1_____cindy' and state='terminated';
|
||||
select is(count(*), 1::bigint) from session_state where session_id = 's1_____ciara' and state='canceling';
|
||||
select is(count(*), 1::bigint) from session_state where session_id = 's1_____carly' and state='active';
|
||||
|
||||
-- Check that we have a session using this target address
|
||||
select is(count(*), 1::bigint) from session_target_address where target_id = 't_________cg';
|
||||
|
||||
-- Delete target address, expect no errors
|
||||
delete from target_address where target_id = 't_________cg';
|
||||
select is(count(*), 0::bigint) from target_address where target_id = 't_________cg';
|
||||
|
||||
-- Ensure we no longer have sessions associated with this target address
|
||||
select is(count(*), 0::bigint) from session_target_address where target_id = 't_________cg';
|
||||
|
||||
-- Ensure sessions that were pending or active are now in canceling state
|
||||
select is(count(*), 1::bigint) from session_state where state = 'canceling' and session_id = 's1______cora';
|
||||
|
||||
select * from finish();
|
||||
rollback;
|
||||
@@ -0,0 +1,28 @@
|
||||
begin;
|
||||
select plan(12);
|
||||
|
||||
-- Ensure session state table is populated
|
||||
select is(count(*), 1::bigint) from session_state where session_id = 's1_____clare' and state='pending';
|
||||
select is(count(*), 1::bigint) from session_state where session_id = 's1_____cindy' and state='terminated';
|
||||
select is(count(*), 1::bigint) from session_state where session_id = 's1_____ciara' and state='canceling';
|
||||
select is(count(*), 1::bigint) from session_state where session_id = 's1_____carly' and state='active';
|
||||
|
||||
-- Check that we have a session for both users
|
||||
select is(count(*), 1::bigint) from session where user_id = 'u______clare';
|
||||
select is(count(*), 1::bigint) from session where user_id = 'u______carly';
|
||||
|
||||
-- Delete users, expect no errors
|
||||
delete from iam_user where public_id = 'u______clare' or public_id = 'u______carly';
|
||||
select is(count(*), 0::bigint) from iam_user where public_id = 'u______clare';
|
||||
select is(count(*), 0::bigint) from iam_user where public_id = 'u______carly';
|
||||
|
||||
-- Ensure we no longer have sessions associated with the users
|
||||
select is(count(*), 0::bigint) from session where user_id = 'u______clare';
|
||||
select is(count(*), 0::bigint) from session where user_id = 'u______carly';
|
||||
|
||||
-- Ensure sessions that were pending or active are now in canceling state
|
||||
select is(count(*), 1::bigint) from session_state where state = 'canceling' and session_id = 's1_____clare';
|
||||
select is(count(*), 1::bigint) from session_state where state = 'canceling' and session_id = 's1_____carly';
|
||||
|
||||
select * from finish();
|
||||
rollback;
|
||||
@@ -10,9 +10,13 @@ begin;
|
||||
|
||||
-- insert first session, should result in a new credentials dimension
|
||||
insert into session
|
||||
( project_id, target_id, host_set_id, host_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
( project_id, target_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
values
|
||||
('p____bwidget', 't_________wb', 's___1wb-sths', 'h_____wb__01', 'u_____walter', 'tok___walter', 'abc'::bytea, 'ep1', 's1____walter');
|
||||
('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');
|
||||
insert into session_credential_dynamic
|
||||
( session_id, library_id, credential_id, credential_purpose)
|
||||
values
|
||||
@@ -25,9 +29,13 @@ begin;
|
||||
-- * same host
|
||||
-- should not result in a new credential dimension
|
||||
insert into session
|
||||
( project_id, target_id, host_set_id, host_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
( project_id, target_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
values
|
||||
('p____bwidget', 't_________wb', 's___1wb-sths', 'h_____wb__01', 'u_____walter', 'tok___walter', 'abc'::bytea, 'ep1', 's2____walter');
|
||||
('p____bwidget', 't_________wb', 'u_____walter', 'tok___walter', 'abc'::bytea, 'ep1', 's2____walter');
|
||||
insert into session_host_set_host
|
||||
(session_id, host_set_id, host_id)
|
||||
values
|
||||
('s2____walter', 's___1wb-sths', 'h_____wb__01');
|
||||
insert into session_credential_dynamic
|
||||
( session_id, library_id, credential_id, credential_purpose)
|
||||
values
|
||||
@@ -39,9 +47,13 @@ begin;
|
||||
|
||||
-- start another session, should result in a new credential dimension
|
||||
insert into session
|
||||
( project_id, target_id, host_set_id, host_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
( project_id, target_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
values
|
||||
('p____bwidget', 't_________wb', 's___1wb-sths', 'h_____wb__01', 'u_____walter', 'tok___walter', 'abc'::bytea, 'ep1', 's3____walter');
|
||||
('p____bwidget', 't_________wb', 'u_____walter', 'tok___walter', 'abc'::bytea, 'ep1', 's3____walter');
|
||||
insert into session_host_set_host
|
||||
(session_id, host_set_id, host_id)
|
||||
values
|
||||
('s3____walter', 's___1wb-sths', 'h_____wb__01');
|
||||
insert into session_credential_dynamic
|
||||
( session_id, library_id, credential_id, credential_purpose)
|
||||
values
|
||||
@@ -50,9 +62,13 @@ begin;
|
||||
|
||||
-- start another session, should result in a one new credential dimensions
|
||||
insert into session
|
||||
( project_id, target_id, host_set_id, host_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
( project_id, target_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
values
|
||||
('p____bwidget', 't_________wb', 's___1wb-sths', 'h_____wb__01', 'u_____walter', 'tok___walter', 'abc'::bytea, 'ep1', 's4____walter');
|
||||
('p____bwidget', 't_________wb', 'u_____walter', 'tok___walter', 'abc'::bytea, 'ep1', 's4____walter');
|
||||
insert into session_host_set_host
|
||||
(session_id, host_set_id, host_id)
|
||||
values
|
||||
('s4____walter', 's___1wb-sths', 'h_____wb__01');
|
||||
insert into session_credential_dynamic
|
||||
( session_id, library_id, credential_id, credential_purpose)
|
||||
values
|
||||
@@ -65,9 +81,13 @@ begin;
|
||||
|
||||
-- start another session, should result in a one new credential dimensions since one changed
|
||||
insert into session
|
||||
( project_id, target_id, host_set_id, host_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
( project_id, target_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
values
|
||||
('p____bwidget', 't_________wb', 's___1wb-sths', 'h_____wb__01', 'u_____walter', 'tok___walter', 'abc'::bytea, 'ep1', 's5____walter');
|
||||
('p____bwidget', 't_________wb', 'u_____walter', 'tok___walter', 'abc'::bytea, 'ep1', 's5____walter');
|
||||
insert into session_host_set_host
|
||||
(session_id, host_set_id, host_id)
|
||||
values
|
||||
('s5____walter', 's___1wb-sths', 'h_____wb__01');
|
||||
insert into session_credential_dynamic
|
||||
( session_id, library_id, credential_id, credential_purpose)
|
||||
values
|
||||
@@ -80,9 +100,13 @@ begin;
|
||||
-- then test creating a session
|
||||
delete from credential_vault_library;
|
||||
insert into session
|
||||
( project_id, target_id, host_set_id, host_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
( project_id, target_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
values
|
||||
('p____bwidget', 't_________wb', 's___1wb-sths', 'h_____wb__01', 'u_____walter', 'tok___walter', 'abc'::bytea, 'ep1', 's6____walter');
|
||||
('p____bwidget', 't_________wb', 'u_____walter', 'tok___walter', 'abc'::bytea, 'ep1', 's6____walter');
|
||||
insert into session_host_set_host
|
||||
(session_id, host_set_id, host_id)
|
||||
values
|
||||
('s6____walter', 's___1wb-sths', 'h_____wb__01');
|
||||
select is(count(*), 4::bigint) from wh_credential_dimension where organization_id = 'o_____widget';
|
||||
select is(credential_group_key, 'no credentials') from wh_session_accumulating_fact where session_id = 's6____walter';
|
||||
insert into session_connection
|
||||
@@ -93,9 +117,13 @@ begin;
|
||||
|
||||
-- insert into a session for a target that never had any credentials associated with it.
|
||||
insert into session
|
||||
( project_id, target_id, host_set_id, host_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
( project_id, target_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
values
|
||||
('p____bwidget', 't_________ws', 's___1ws-sths', 'h_____ws__01', 'u_____walter', 'tok___walter', 'abc'::bytea, 'ep1', 's7____walter');
|
||||
('p____bwidget', 't_________ws', 'u_____walter', 'tok___walter', 'abc'::bytea, 'ep1', 's7____walter');
|
||||
insert into session_host_set_host
|
||||
(session_id, host_set_id, host_id)
|
||||
values
|
||||
('s7____walter', 's___1ws-sths', 'h_____ws__01');
|
||||
select is(count(*), 4::bigint) from wh_credential_dimension where organization_id = 'o_____widget';
|
||||
select is(credential_group_key, 'no credentials') from wh_session_accumulating_fact where session_id = 's7____walter';
|
||||
insert into session_connection
|
||||
|
||||
@@ -10,9 +10,13 @@ begin;
|
||||
|
||||
-- insert first session, should result in a new user dimension
|
||||
insert into session
|
||||
( project_id, target_id, host_set_id, host_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
( project_id, target_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
values
|
||||
('p____bwidget', 't_________wb', 's___1wb-sths', 'h_____wb__01', 'u_____walter', 'tok___walter', 'abc'::bytea, 'ep1', 's1____walter');
|
||||
('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');
|
||||
insert into session_credential_dynamic
|
||||
( session_id, library_id, credential_id, credential_purpose)
|
||||
values
|
||||
|
||||
@@ -14,9 +14,13 @@ begin;
|
||||
|
||||
-- insert session and session_credential_dynamic, should result in a three new credential dimensions
|
||||
insert into session
|
||||
( project_id, target_id, host_set_id, host_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
( project_id, target_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
values
|
||||
('p____bwidget', 't_________wb', 's___1wb-sths', 'h_____wb__01', 'u_____walter', 'tok___walter', 'abc'::bytea, 'ep1', 's1____walter');
|
||||
('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');
|
||||
insert into session_credential_dynamic
|
||||
( session_id, library_id, credential_id, credential_purpose)
|
||||
values
|
||||
@@ -29,9 +33,13 @@ begin;
|
||||
update credential_vault_library set vault_path = '/secrets/tcp/user' where public_id = 'vl______wvl2';
|
||||
|
||||
insert into session
|
||||
( project_id, target_id, host_set_id, host_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
( project_id, target_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
values
|
||||
('p____bwidget', 't_________wb', 's___1wb-sths', 'h_____wb__01', 'u_____walter', 'tok___walter', 'abc'::bytea, 'ep1', 's2____walter');
|
||||
('p____bwidget', 't_________wb', 'u_____walter', 'tok___walter', 'abc'::bytea, 'ep1', 's2____walter');
|
||||
insert into session_host_set_host
|
||||
(session_id, host_set_id, host_id)
|
||||
values
|
||||
('s2____walter', 's___1wb-sths', 'h_____wb__01');
|
||||
insert into session_credential_dynamic
|
||||
( session_id, library_id, credential_id, credential_purpose)
|
||||
values
|
||||
|
||||
@@ -4,9 +4,13 @@ begin;
|
||||
|
||||
select wtt_load('widgets', 'iam', 'kms', 'auth', 'hosts', 'targets', 'credentials');
|
||||
insert into session
|
||||
( project_id, target_id, host_set_id, host_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
( project_id, target_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
values
|
||||
('p____bwidget', 't_________wb', 's___1wb-sths', 'h_____wb__01', 'u_____walter', 'tok___walter', 'abc'::bytea, 'ep1', 's1____walter');
|
||||
('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');
|
||||
insert into session_credential_dynamic
|
||||
( session_id, library_id, credential_id, credential_purpose)
|
||||
values
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
begin;
|
||||
select plan(8);
|
||||
|
||||
select wtt_load('widgets', 'iam', 'kms', 'auth', 'hosts', 'targets');
|
||||
|
||||
-- ensure no existing dimensions
|
||||
select is(count(*), 0::bigint) from wh_host_dimension where organization_id = 'o_____widget';
|
||||
|
||||
-- create network address dimension using static host
|
||||
insert into session
|
||||
( project_id , target_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
values
|
||||
('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');
|
||||
|
||||
select is(count(*), 1::bigint) from wh_host_dimension where organization_id = 'o_____widget';
|
||||
select is(count(*), 1::bigint) from wh_network_address_dimension
|
||||
where address = '1.big.widget'
|
||||
and address_type = 'DNS Name'
|
||||
and ip_address_family = 'Not Applicable'
|
||||
and private_ip_address_indicator = 'Not Applicable'
|
||||
and dns_name = '1.big.widget'
|
||||
and ip4_address = 'Not Applicable'
|
||||
and ip6_address = 'Not Applicable';
|
||||
select is(count(*), 1::bigint)
|
||||
from wh_network_address_group_membership g
|
||||
left join wh_host_dimension h on g.network_address_group_key = h.network_address_group_key
|
||||
where g.network_address = '1.big.widget'
|
||||
and h.target_id = 't_________wb'
|
||||
and h.host_id = 'h_____wb__01'
|
||||
and h.host_set_id = 's___1wb-sths'
|
||||
and h.current_row_indicator = 'Current';
|
||||
|
||||
-- delete target host source associations to enforce mutually exclusive relationship to a target address
|
||||
delete from target_host_set where target_id = 't_________wb';
|
||||
|
||||
-- update target to use the same address, but as a direct network address association
|
||||
insert into target_address
|
||||
(target_id, address)
|
||||
values
|
||||
('t_________wb', '1.big.widget');
|
||||
select is(count(*), 0::bigint) from target_host_set where target_id = 't_________wb';
|
||||
|
||||
insert into session
|
||||
( project_id , target_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
values
|
||||
('p____bwidget' , 't_________wb' , 'u_____walter' , 'tok___walter' , 'abc'::bytea , 'ep1' , 's2____walter');
|
||||
insert into session_target_address
|
||||
(session_id, target_id)
|
||||
values
|
||||
('s2____walter', 't_________wb');
|
||||
|
||||
-- this should have expired the old host_dimension that had values inserted in the columns related to hosts, host sets, & host catalogs.
|
||||
-- this should have created a new host_dimension for a static address with 'Not Applicable' values set for columns related to hosts, host sets, & host catalogs.
|
||||
-- this should have used the existing network_address_dimension created from the session using a host source
|
||||
select is(count(*), 2::bigint) from wh_host_dimension where organization_id = 'o_____widget';
|
||||
select is(count(*), 1::bigint) from wh_network_address_dimension
|
||||
where address = '1.big.widget'
|
||||
and address_type = 'DNS Name'
|
||||
and ip_address_family = 'Not Applicable'
|
||||
and private_ip_address_indicator = 'Not Applicable'
|
||||
and dns_name = '1.big.widget'
|
||||
and ip4_address = 'Not Applicable'
|
||||
and ip6_address = 'Not Applicable';
|
||||
select is(count(*), 1::bigint)
|
||||
from wh_network_address_group_membership g
|
||||
left join wh_host_dimension h on g.network_address_group_key = h.network_address_group_key
|
||||
where g.network_address = '1.big.widget'
|
||||
and h.target_id = 't_________wb'
|
||||
and h.host_id = 'Not Applicable'
|
||||
and h.host_set_id = 'Not Applicable'
|
||||
and h.current_row_indicator = 'Current';
|
||||
|
||||
select * from finish();
|
||||
rollback;
|
||||
@@ -10,10 +10,13 @@ begin;
|
||||
|
||||
-- insert first session, should result in a new host dimension
|
||||
insert into session
|
||||
( project_id , target_id , host_set_id , host_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
( project_id , target_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
values
|
||||
('p____bwidget' , 't_________wb' , 's___1wb-plghs' , 'h_____wb__02-plgh' , 'u_____walter' , 'tok___walter' , 'abc'::bytea , 'ep1' , 's1____walter');
|
||||
|
||||
('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-plghs', 'h_____wb__02-plgh');
|
||||
select is(count(*), 1::bigint) from wh_host_dimension where organization_id = 'o_____widget';
|
||||
|
||||
-- another session with:
|
||||
@@ -22,10 +25,14 @@ begin;
|
||||
-- * same host
|
||||
-- should not result in a new host dimension
|
||||
insert into session
|
||||
( project_id , target_id , host_set_id , host_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
( project_id , target_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
values
|
||||
('p____bwidget' , 't_________wb' , 's___1wb-plghs' , 'h_____wb__02-plgh' , 'u_____walter' , 'tok___walter' , 'abc'::bytea , 'ep1' , 's2____walter');
|
||||
|
||||
('p____bwidget' , 't_________wb' , 'u_____walter' , 'tok___walter' , 'abc'::bytea , 'ep1' , 's2____walter');
|
||||
insert into session_host_set_host
|
||||
(session_id, host_set_id, host_id)
|
||||
values
|
||||
('s2____walter', 's___1wb-plghs', 'h_____wb__02-plgh');
|
||||
|
||||
select is(count(*), 1::bigint) from wh_host_dimension where organization_id = 'o_____widget';
|
||||
|
||||
-- another session with:
|
||||
@@ -34,9 +41,13 @@ begin;
|
||||
-- * same host
|
||||
-- should not result in a new host dimension
|
||||
insert into session
|
||||
( project_id , target_id , host_set_id , host_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
( project_id , target_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
values
|
||||
('p____bwidget' , 't_________wb' , 's___1wb-plghs' , 'h_____wb__02-plgh' , 'u_____warren' , 'tok___warren' , 'abc'::bytea , 'ep1' , 's3____walter');
|
||||
('p____bwidget' , 't_________wb' , 'u_____warren' , 'tok___warren' , 'abc'::bytea , 'ep1' , 's3____walter');
|
||||
insert into session_host_set_host
|
||||
(session_id, host_set_id, host_id)
|
||||
values
|
||||
('s3____walter', 's___1wb-plghs', 'h_____wb__02-plgh');
|
||||
|
||||
select is(count(*), 1::bigint) from wh_host_dimension where organization_id = 'o_____widget';
|
||||
|
||||
@@ -52,9 +63,13 @@ begin;
|
||||
|
||||
-- should result in a new host dimension
|
||||
insert into session
|
||||
( project_id , target_id , host_set_id , host_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
( project_id , target_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
values
|
||||
('p____bwidget' , 't_________wb' , 's___1wb-plghs' , 'h_____wb__02-plgh' , 'u_____walter' , 'tok___walter' , 'abc'::bytea , 'ep1' , 's4____walter');
|
||||
('p____bwidget' , 't_________wb' , 'u_____walter' , 'tok___walter' , 'abc'::bytea , 'ep1' , 's4____walter');
|
||||
insert into session_host_set_host
|
||||
(session_id, host_set_id, host_id)
|
||||
values
|
||||
('s4____walter', 's___1wb-plghs', 'h_____wb__02-plgh');
|
||||
|
||||
select is(count(*), 2::bigint) from wh_host_dimension where organization_id = 'o_____widget';
|
||||
|
||||
@@ -70,9 +85,13 @@ begin;
|
||||
|
||||
-- should result in a new host dimension
|
||||
insert into session
|
||||
( project_id , target_id , host_set_id , host_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
( project_id , target_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
values
|
||||
('p____bwidget' , 't_________wb' , 's___1wb-plghs' , 'h_____wb__02-plgh' , 'u_____walter' , 'tok___walter' , 'abc'::bytea , 'ep1' , 's5____walter');
|
||||
('p____bwidget' , 't_________wb' , 'u_____walter' , 'tok___walter' , 'abc'::bytea , 'ep1' , 's5____walter');
|
||||
insert into session_host_set_host
|
||||
(session_id, host_set_id, host_id)
|
||||
values
|
||||
('s5____walter', 's___1wb-plghs', 'h_____wb__02-plgh');
|
||||
|
||||
select is(count(*), 3::bigint) from wh_host_dimension where organization_id = 'o_____widget';
|
||||
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
begin;
|
||||
select plan(12);
|
||||
|
||||
select wtt_load('widgets', 'iam', 'kms', 'auth', 'hosts', 'targets');
|
||||
|
||||
-- ensure no existing dimensions
|
||||
select is(count(*), 0::bigint) from wh_host_dimension where organization_id = 'o_____widget';
|
||||
|
||||
-- setup target to use a ipv4 static address
|
||||
insert into target_address
|
||||
(target_id, address)
|
||||
values
|
||||
('t_________wb', '8.6.4.2');
|
||||
|
||||
-- insert first session, should result in a new host dimension
|
||||
insert into session
|
||||
( project_id , target_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
values
|
||||
('p____bwidget' , 't_________wb' , 'u_____walter' , 'tok___walter' , 'abc'::bytea , 'ep1' , 's1____walter');
|
||||
insert into session_target_address
|
||||
(session_id, target_id)
|
||||
values
|
||||
('s1____walter', 't_________wb');
|
||||
select is(count(*), 1::bigint) from wh_host_dimension where organization_id = 'o_____widget';
|
||||
|
||||
-- expected wh_network_address_dimension row is created for ipv4
|
||||
select is(count(*), 1::bigint) from wh_network_address_dimension
|
||||
where address = '8.6.4.2'
|
||||
and address_type = 'IP Address'
|
||||
and ip_address_family = 'IPv4'
|
||||
and private_ip_address_indicator = 'Public IP address'
|
||||
and dns_name = 'Not Applicable'
|
||||
and ip4_address = '8.6.4.2'
|
||||
and ip6_address = 'Not Applicable';
|
||||
|
||||
-- expected wh_network_address_group_membership has one row: '8.6.4.2'
|
||||
select is(count(*), 1::bigint)
|
||||
from wh_network_address_group_membership gm,
|
||||
wh_host_dimension h
|
||||
where h.network_address_group_key = gm.network_address_group_key
|
||||
and h.host_id = 'Not Applicable'
|
||||
and h.host_set_id = 'Not Applicable'
|
||||
and h.host_catalog_id = 'Not Applicable'
|
||||
and h.target_id = 't_________wb';
|
||||
|
||||
-- update target address association to ipv6
|
||||
update target_address set address = 'fe60::6667:5556:4445:3334' where target_id = 't_________wb';
|
||||
insert into session
|
||||
( project_id , target_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
values
|
||||
('p____bwidget' , 't_________wb' , 'u_____walter' , 'tok___walter' , 'abc'::bytea , 'ep1' , 's2____walter');
|
||||
insert into session_target_address
|
||||
(session_id, target_id)
|
||||
values
|
||||
('s2____walter', 't_________wb');
|
||||
|
||||
-- should not result in a new host dimension
|
||||
select is(count(*), 1::bigint) from wh_host_dimension where organization_id = 'o_____widget';
|
||||
|
||||
-- expected wh_network_address_dimension row is created for ipv6
|
||||
select is(count(*), 1::bigint) from wh_network_address_dimension
|
||||
where address = 'fe60::6667:5556:4445:3334'
|
||||
and address_type = 'IP Address'
|
||||
and ip_address_family = 'IPv6'
|
||||
and private_ip_address_indicator = 'Public IP address'
|
||||
and dns_name = 'Not Applicable'
|
||||
and ip4_address = 'Not Applicable'
|
||||
and ip6_address = 'fe60::6667:5556:4445:3334';
|
||||
|
||||
-- expected wh_network_address_group_membership has two rows: '8.6.4.2' & 'fe60::6667:5556:4445:3334'
|
||||
select is(count(*), 2::bigint)
|
||||
from wh_network_address_group_membership gm,
|
||||
wh_host_dimension h
|
||||
where h.network_address_group_key = gm.network_address_group_key
|
||||
and h.host_id = 'Not Applicable'
|
||||
and h.host_set_id = 'Not Applicable'
|
||||
and h.host_catalog_id = 'Not Applicable'
|
||||
and h.target_id = 't_________wb';
|
||||
|
||||
-- update static address association to dns name
|
||||
update target_address set address = '0.blue.green' where target_id = 't_________wb';
|
||||
insert into session
|
||||
( project_id , target_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
values
|
||||
('p____bwidget' , 't_________wb' , 'u_____walter' , 'tok___walter' , 'abc'::bytea , 'ep1' , 's3____walter');
|
||||
insert into session_target_address
|
||||
(session_id, target_id)
|
||||
values
|
||||
('s3____walter', 't_________wb');
|
||||
|
||||
-- should not result in a new host dimension
|
||||
select is(count(*), 1::bigint) from wh_host_dimension where organization_id = 'o_____widget';
|
||||
|
||||
-- expected wh_network_address_dimension row is created for dns
|
||||
select is(count(*), 1::bigint) from wh_network_address_dimension
|
||||
where address = '0.blue.green'
|
||||
and address_type = 'DNS Name'
|
||||
and ip_address_family = 'Not Applicable'
|
||||
and private_ip_address_indicator = 'Not Applicable'
|
||||
and dns_name = '0.blue.green'
|
||||
and ip4_address = 'Not Applicable'
|
||||
and ip6_address = 'Not Applicable';
|
||||
|
||||
-- expected wh_network_address_group_membership has three rows: '8.6.4.2' & 'fe60::6667:5556:4445:3334' & '0.blue.green'
|
||||
select is(count(*), 3::bigint)
|
||||
from wh_network_address_group_membership gm,
|
||||
wh_host_dimension h
|
||||
where h.network_address_group_key = gm.network_address_group_key
|
||||
and h.host_id = 'Not Applicable'
|
||||
and h.host_set_id = 'Not Applicable'
|
||||
and h.host_catalog_id = 'Not Applicable'
|
||||
and h.target_id = 't_________wb';
|
||||
|
||||
-- create second session with the same resources
|
||||
insert into session
|
||||
( project_id , target_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
values
|
||||
('p____bwidget' , 't_________wb' , 'u_____walter' , 'tok___walter' , 'abc'::bytea , 'ep1' , 's4____walter');
|
||||
insert into session_target_address
|
||||
(session_id, target_id)
|
||||
values
|
||||
('s4____walter', 't_________wb');
|
||||
|
||||
-- should not result in a new host dimension
|
||||
select is(count(*), 1::bigint) from wh_host_dimension where organization_id = 'o_____widget';
|
||||
|
||||
-- expected wh_network_address_group_membership does not change.
|
||||
select is(count(*), 3::bigint)
|
||||
from wh_network_address_group_membership gm,
|
||||
wh_host_dimension h
|
||||
where h.network_address_group_key = gm.network_address_group_key
|
||||
and h.host_id = 'Not Applicable'
|
||||
and h.host_set_id = 'Not Applicable'
|
||||
and h.host_catalog_id = 'Not Applicable'
|
||||
and h.target_id = 't_________wb';
|
||||
|
||||
select * from finish();
|
||||
rollback;
|
||||
@@ -10,9 +10,13 @@ begin;
|
||||
|
||||
-- insert first session, should result in a new host dimension
|
||||
insert into session
|
||||
( project_id , target_id , host_set_id , host_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
( project_id , target_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
values
|
||||
('p____bwidget' , 't_________wb' , 's___1wb-plghs' , 'h_____wb__01-plgh' , 'u_____walter' , 'tok___walter' , 'abc'::bytea , 'ep1' , 's1____walter');
|
||||
('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-plghs', 'h_____wb__01-plgh');
|
||||
|
||||
select is(count(*), 1::bigint) from wh_host_dimension where organization_id = 'o_____widget';
|
||||
|
||||
|
||||
@@ -9,9 +9,13 @@ begin;
|
||||
|
||||
-- insert first session, should result in a new wh_session_accumulating_fact
|
||||
insert into session
|
||||
( project_id , target_id , host_set_id , host_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
( project_id , target_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
values
|
||||
('p____bwidget' , 't_________wb' , 's___1wb-sths' , 'h_____wb__01' , 'u_____walter' , 'tok___walter' , 'abc'::bytea , 'ep1' , 's1____walter');
|
||||
('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');
|
||||
|
||||
select is(count(*), 1::bigint) from wh_session_accumulating_fact where session_id = 's1____walter';
|
||||
|
||||
|
||||
@@ -8,10 +8,13 @@ begin;
|
||||
select is(count(*), 0::bigint) from wh_session_connection_accumulating_fact where connection_id = 'sc1____walter';
|
||||
|
||||
insert into session
|
||||
( project_id , target_id , host_set_id , host_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
( project_id , target_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
values
|
||||
('p____bwidget' , 't_________wb' , 's___1wb-sths' , 'h_____wb__01' , 'u_____walter' , 'tok___walter' , 'abc'::bytea , 'ep1' , 's1____walter');
|
||||
|
||||
('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');
|
||||
insert into session_connection
|
||||
(session_id, public_id)
|
||||
values
|
||||
|
||||
@@ -10,10 +10,13 @@ begin;
|
||||
|
||||
--- insert single credential
|
||||
insert into session
|
||||
( project_id, target_id, host_set_id, host_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
( project_id, target_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
values
|
||||
('p____bwidget', 't_________wb', 's___1wb-sths', 'h_____wb__01', 'u_____walter', 'tok___walter', 'abc'::bytea, 'ep1', 's1____walter');
|
||||
|
||||
('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');
|
||||
insert into session_credential_dynamic
|
||||
( session_id, library_id, credential_id, credential_purpose)
|
||||
values
|
||||
|
||||
@@ -10,9 +10,13 @@ begin;
|
||||
|
||||
--- multiple single credentials
|
||||
insert into session
|
||||
( project_id, target_id, host_set_id, host_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
( project_id, target_id, user_id, auth_token_id, certificate, endpoint, public_id)
|
||||
values
|
||||
('p____bwidget', 't_________wb', 's___1wb-sths', 'h_____wb__01', 'u_____walter', 'tok___walter', 'abc'::bytea, 'ep1', 's1____walter');
|
||||
('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');
|
||||
insert into session_credential_dynamic
|
||||
( session_id, library_id, credential_id, credential_purpose)
|
||||
values
|
||||
|
||||
@@ -10,9 +10,13 @@ begin;
|
||||
|
||||
-- insert first session, should result in a new user dimension
|
||||
insert into session
|
||||
( project_id , target_id , host_set_id , host_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
( project_id , target_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
values
|
||||
('p____bwidget' , 't_________wb' , 's___1wb-sths' , 'h_____wb__01' , 'u_____walter' , 'oidc__walter' , 'abc'::bytea , 'ep1' , 's1____walter');
|
||||
('p____bwidget' , 't_________wb' , 'u_____walter' , 'oidc__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');
|
||||
|
||||
select is(count(*), 1::bigint) from wh_user_dimension where user_id = 'u_____walter';
|
||||
select is(user_id, 'u_____walter') from wh_user_dimension where user_id = 'u_____walter';
|
||||
@@ -41,9 +45,13 @@ begin;
|
||||
|
||||
-- insert session without full name or email
|
||||
insert into session
|
||||
( project_id , target_id , host_set_id , host_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
( project_id , target_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
values
|
||||
('p____bwidget' , 't_________wb' , 's___1wb-sths' , 'h_____wb__01' , 'u_____warren' , 'oidc__warren' , 'abc'::bytea , 'ep1' , 's1____warren');
|
||||
('p____bwidget' , 't_________wb' , 'u_____warren' , 'oidc__warren' , 'abc'::bytea , 'ep1' , 's1____warren');
|
||||
insert into session_host_set_host
|
||||
(session_id, host_set_id, host_id)
|
||||
values
|
||||
('s1____warren', 's___1wb-sths', 'h_____wb__01');
|
||||
|
||||
select is(count(*), 1::bigint) from wh_user_dimension where user_id = 'u_____warren';
|
||||
select is(user_name, 'Warren') from wh_user_dimension where user_id = 'u_____warren';
|
||||
|
||||
@@ -11,9 +11,13 @@ begin;
|
||||
|
||||
-- insert first session, should result in a new user dimension
|
||||
insert into session
|
||||
( project_id , target_id , host_set_id , host_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
( project_id , target_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
values
|
||||
('p____bwidget' , 't_________wb' , 's___1wb-sths' , 'h_____wb__01' , 'u_____walter' , 'tok___walter' , 'abc'::bytea , 'ep1' , 's1____walter');
|
||||
('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');
|
||||
|
||||
select is(count(*), 1::bigint) from wh_user_dimension where user_id = 'u_____walter';
|
||||
select is(user_id, 'u_____walter') from wh_user_dimension where user_id = 'u_____walter';
|
||||
@@ -52,9 +56,13 @@ begin;
|
||||
-- * same host
|
||||
-- should result in a new user dimension due to auth change.
|
||||
insert into session
|
||||
( project_id , target_id , host_set_id , host_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
( project_id , target_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
values
|
||||
('p____bwidget' , 't_________wb' , 's___1wb-sths' , 'h_____wb__01' , 'u_____walter' , 'tok___walter' , 'abc'::bytea , 'ep1' , 's2____walter');
|
||||
('p____bwidget' , 't_________wb' , 'u_____walter' , 'tok___walter' , 'abc'::bytea , 'ep1' , 's2____walter');
|
||||
insert into session_host_set_host
|
||||
(session_id, host_set_id, host_id)
|
||||
values
|
||||
('s2____walter', 's___1wb-sths', 'h_____wb__01');
|
||||
|
||||
select is(count(*), 2::bigint) from wh_user_dimension where user_organization_id = 'o_____widget';
|
||||
|
||||
|
||||
@@ -10,9 +10,13 @@ begin;
|
||||
|
||||
-- insert first session, should result in a new user dimension
|
||||
insert into session
|
||||
( project_id , target_id , host_set_id , host_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
( project_id , target_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
values
|
||||
('p____bwidget' , 't_________wb' , 's___1wb-sths' , 'h_____wb__01' , 'u_____walter' , 'tok___walter' , 'abc'::bytea , 'ep1' , 's1____walter');
|
||||
('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');
|
||||
|
||||
select is(count(*), 1::bigint) from wh_user_dimension where user_id = 'u_____walter';
|
||||
select is(user_id, 'u_____walter') from wh_user_dimension where user_id = 'u_____walter';
|
||||
|
||||
@@ -10,9 +10,13 @@ begin;
|
||||
|
||||
-- insert first session, should result in a new user dimension
|
||||
insert into session
|
||||
( project_id , target_id , host_set_id , host_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
( project_id , target_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
values
|
||||
('p____bwidget' , 't_________wb' , 's___1wb-sths' , 'h_____wb__01' , 'u_____walter' , 'tok___walter' , 'abc'::bytea , 'ep1' , 's1____walter');
|
||||
('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');
|
||||
|
||||
select is(count(*), 1::bigint) from wh_user_dimension where user_organization_id = 'o_____widget';
|
||||
|
||||
@@ -22,9 +26,13 @@ begin;
|
||||
-- * same host
|
||||
-- should not result in a new user dimension
|
||||
insert into session
|
||||
( project_id , target_id , host_set_id , host_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
( project_id , target_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
values
|
||||
('p____bwidget' , 't_________wb' , 's___1wb-sths' , 'h_____wb__01' , 'u_____walter' , 'tok___walter' , 'abc'::bytea , 'ep1' , 's2____walter');
|
||||
('p____bwidget' , 't_________wb' , 'u_____walter' , 'tok___walter' , 'abc'::bytea , 'ep1' , 's2____walter');
|
||||
insert into session_host_set_host
|
||||
(session_id, host_set_id, host_id)
|
||||
values
|
||||
('s2____walter', 's___1wb-sths', 'h_____wb__01');
|
||||
|
||||
select is(count(*), 1::bigint) from wh_user_dimension where user_organization_id = 'o_____widget';
|
||||
|
||||
@@ -34,9 +42,13 @@ begin;
|
||||
-- * different host
|
||||
-- should not result in a new user dimension
|
||||
insert into session
|
||||
( project_id , target_id , host_set_id , host_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
( project_id , target_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
values
|
||||
('p____bwidget' , 't_________wb' , 's___1wb-sths' , 'h_____wb__02' , 'u_____walter' , 'tok___walter' , 'abc'::bytea , 'ep1' , 's3____walter');
|
||||
('p____bwidget' , 't_________wb' , 'u_____walter' , 'tok___walter' , 'abc'::bytea , 'ep1' , 's3____walter');
|
||||
insert into session_host_set_host
|
||||
(session_id, host_set_id, host_id)
|
||||
values
|
||||
('s3____walter', 's___1wb-sths', 'h_____wb__01');
|
||||
|
||||
select is(count(*), 1::bigint) from wh_user_dimension where user_organization_id = 'o_____widget';
|
||||
|
||||
|
||||
+12
-4
@@ -11,9 +11,13 @@ begin;
|
||||
|
||||
-- insert first session, should result in a new user dimension
|
||||
insert into session
|
||||
( project_id , target_id , host_set_id , host_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
( project_id , target_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
values
|
||||
('p____bwidget' , 't_________wb' , 's___1wb-sths' , 'h_____wb__01' , 'u_____walter' , 'tok___walter' , 'abc'::bytea , 'ep1' , 's1____walter');
|
||||
('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');
|
||||
|
||||
select is(count(*), 1::bigint) from wh_user_dimension where user_organization_id = 'o_____widget';
|
||||
|
||||
@@ -23,9 +27,13 @@ begin;
|
||||
-- * same host
|
||||
-- should result in a new user dimension
|
||||
insert into session
|
||||
( project_id , target_id , host_set_id , host_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
( project_id , target_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
values
|
||||
('p____bwidget' , 't_________wb' , 's___1wb-sths' , 'h_____wb__01' , 'u_____walter' , 'tok1__walter' , 'abc'::bytea , 'ep1' , 's4____walter');
|
||||
('p____bwidget' , 't_________wb' , 'u_____walter' , 'tok1__walter' , 'abc'::bytea , 'ep1' , 's4____walter');
|
||||
insert into session_host_set_host
|
||||
(session_id, host_set_id, host_id)
|
||||
values
|
||||
('s4____walter', 's___1wb-sths', 'h_____wb__01');
|
||||
|
||||
select is(count(*), 2::bigint) from wh_user_dimension where user_organization_id = 'o_____widget';
|
||||
select is(count(*), 1::bigint) from wh_user_dimension where user_id = 'u_____walter' and auth_account_id = 'apa1__walter';
|
||||
|
||||
@@ -10,9 +10,13 @@ begin;
|
||||
|
||||
-- insert first session, should result in a new user dimension
|
||||
insert into session
|
||||
( project_id , target_id , host_set_id , host_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
( project_id , target_id , user_id , auth_token_id , certificate , endpoint , public_id)
|
||||
values
|
||||
('p____bwidget' , 't_________wb' , 's___1wb-sths' , 'h_____wb__01' , 'u_____walter' , 'tok___walter' , 'abc'::bytea , 'ep1' , 's1____walter');
|
||||
('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');
|
||||
|
||||
select is(count(*), 1::bigint) from wh_user_dimension where user_organization_id = 'o_____widget';
|
||||
|
||||
|
||||
Reference in new issue
Block a user