add user_sis_id and user_login to live events

* specifically to user_created and user_updated

closes PLAT-4829

test plan:
* enable live events (see doc/live_events.md) on your local machine
* create a user with a sis id
* the live event generated should contain these 2 new fields
* update that user
* the live event generated should contain these 2 new fields

Change-Id: Ic199173ba9cd54723dba73dcc381be7b6de644aa
Reviewed-on: https://gerrit.instructure.com/209171
Reviewed-by: Marc Phillips <mphillips@instructure.com>
Tested-by: Jenkins
QA-Review: Weston Dransfield <wdransfield@instructure.com>
Product-Review: Xander Moffatt <xmoffatt@instructure.com>
This commit is contained in:
Xander Moffatt 2019-09-12 08:15:43 -06:00
parent edf0c532bd
commit a06b02c090
3 changed files with 54 additions and 1 deletions

View File

@ -48,6 +48,13 @@ You can view the stream with the `tail_kinesis` tool:
docker-compose run --rm web script/tail_kinesis http://kinesis:4567 live-events
```
#### Stubbing Kinesis
Instead of viewing events in the kinesis stream, you can also add this env variable
to your docker compose configuration: `STUB_LIVE_EVENTS_KINESIS`, with any value.
This will redirect live events from the kinesis stream to stdout. You still have
to configure the live events plugin for this to work.
#### Connecting to local Publisher Lambda
The `live-events-publish repo should be checked out and running locally.

View File

@ -317,7 +317,9 @@ module Canvas::LiveEvents
short_name: user.short_name,
workflow_state: user.workflow_state,
created_at: user.created_at,
updated_at: user.updated_at
updated_at: user.updated_at,
user_login: user.primary_pseudonym&.unique_id,
user_sis_id: user.primary_pseudonym&.sis_user_id
}
end

View File

@ -1163,4 +1163,48 @@ describe Canvas::LiveEvents do
end
end
end
describe 'user' do
context 'created' do
it 'should trigger a user_created live event' do
user_with_pseudonym
expect_event('user_created', {
user_id: @user.global_id.to_s,
uuid: @user.uuid,
name: @user.name,
short_name: @user.short_name,
workflow_state: @user.workflow_state,
created_at: @user.created_at,
updated_at: @user.updated_at,
user_login: @pseudonym&.unique_id,
user_sis_id: @pseudonym&.sis_user_id
}.compact!).once
Canvas::LiveEvents.user_created(@user)
end
end
context 'updated' do
it 'should trigger a user_updated live event' do
user_with_pseudonym
@user.update!(name: "Test Name")
expect_event('user_updated', {
user_id: @user.global_id.to_s,
uuid: @user.uuid,
name: @user.name,
short_name: @user.short_name,
workflow_state: @user.workflow_state,
created_at: @user.created_at,
updated_at: @user.updated_at,
user_login: @pseudonym&.unique_id,
user_sis_id: @pseudonym&.sis_user_id
}.compact!).once
Canvas::LiveEvents.user_updated(@user)
end
end
end
end