Skip to content
This repository was archived by the owner on Dec 18, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
5f57938
add translation for Log
MuStAgEDelta Apr 6, 2022
992980a
add translation
MuStAgEDelta Apr 6, 2022
208e9af
Started frontend implementation of Log butten/page
Apr 6, 2022
903cecd
Continued frontend implementation for personal log. Refresh on /log d…
Apr 7, 2022
fc1cb07
removed nav side bar from log page and fixed prettier/prettier error
Apr 7, 2022
4bcdc37
Changed icon for Log in nav bar drop down menu, took the closest one …
Apr 7, 2022
24dd076
Fixed refresh bug when on /log page. (the bug mentioned in earlier co…
Apr 8, 2022
cdeccd3
shows encryptables on dashboard
renato-oester Apr 8, 2022
f52c87a
Added basic frontend test for nav bar
Apr 8, 2022
7c435b2
deleted unused code
Apr 8, 2022
77dbbad
Merge branch '564-LOG_encryptable_read_access' into 572-LOG-recent-cr…
renato-oester Apr 8, 2022
4d42a80
Revert "deleted unused code"
Apr 8, 2022
a7ab1c3
Merge branch '564-LOG_encryptable_read_access' into LOG-568-log-perso…
MuStAgEDelta Apr 8, 2022
08148e6
Merge branch '564-LOG_encryptable_read_access' into LOG-568-log-perso…
MuStAgEDelta Apr 8, 2022
08b59b3
Add spec Test file for the Personal log
MuStAgEDelta Apr 11, 2022
0eb1257
change name and add testes
MuStAgEDelta Apr 11, 2022
47fcb57
Merge branch '564-LOG_encryptable_read_access' into LOG-568-log-perso…
MuStAgEDelta Apr 11, 2022
81548f8
change a 'not' mistake
MuStAgEDelta Apr 11, 2022
053d3b8
Adds system specs for encryptables on dashboard
renato-oester Apr 11, 2022
60d4860
Fixes frontend spec for dashboard-card
renato-oester Apr 11, 2022
ff98791
Merge branch '564-LOG_encryptable_read_access' into 572-LOG-recent-cr…
renato-oester Apr 12, 2022
2ad2f14
Merge branch '564-LOG_encryptable_read_access' into LOG-568-log-perso…
Apr 26, 2022
bd243a2
Updated table in personal log.
Apr 26, 2022
b71a8ad
Added missing files from last commit
Apr 26, 2022
5e820e6
Merge branch '564-LOG_encryptable_read_access' into LOG-568-log-perso…
Apr 28, 2022
682f3e0
Renamed all files for personal log to personal_logs (was log before)
Apr 28, 2022
032c002
Fixed prettier/prettier errors and renamed one more file to personal_…
Apr 28, 2022
6003693
Fixed one more file with prettier/prettier errors
Apr 28, 2022
516c69b
personal log now loads logs from backend, first working version
Apr 28, 2022
00f99a8
some minor improvements, but personal log only works if you access it…
Apr 28, 2022
0dafe6c
Merge branch 'LOG-568-log-personal-activity-log' into 572-LOG-recent-…
renato-oester Apr 29, 2022
f3098c0
Loads recent credentials from encryptables controller
renato-oester May 1, 2022
4bf8702
cleanup encryptables_controller.rb
renato-oester May 1, 2022
af95ba9
Merge branch '564-LOG_encryptable_read_access' into 572-LOG-recent-cr…
renato-oester May 1, 2022
c6f0c44
Revert "some minor improvements, but personal log only works if you a…
renato-oester May 1, 2022
91b0790
Revert "personal log now loads logs from backend, first working version"
renato-oester May 1, 2022
64c66db
Revert "Fixed one more file with prettier/prettier errors"
renato-oester May 1, 2022
4e8b392
Revert "Fixed prettier/prettier errors and renamed one more file to p…
renato-oester May 1, 2022
11d0af6
Revert "Renamed all files for personal log to personal_logs (was log …
renato-oester May 1, 2022
c8e039e
Revert "Added missing files from last commit"
renato-oester May 1, 2022
e2be0a9
Revert "Updated table in personal log."
renato-oester May 1, 2022
40616c4
Revert " change a 'not' mistake"
renato-oester May 1, 2022
2362172
Revert " change name and add testes"
renato-oester May 1, 2022
b21a88f
Revert " Add spec Test file for the Personal log"
renato-oester May 1, 2022
073140a
Revert "Revert "deleted unused code""
renato-oester May 1, 2022
f366c67
Revert "deleted unused code"
renato-oester May 1, 2022
41efcc6
Revert "Added basic frontend test for nav bar"
renato-oester May 1, 2022
43b56e6
Revert "Fixed refresh bug when on /log page. (the bug mentioned in ea…
renato-oester May 1, 2022
67b11f2
Revert "Changed icon for Log in nav bar drop down menu, took the clos…
renato-oester May 1, 2022
d62d0a7
Revert "removed nav side bar from log page and fixed prettier/prettie…
renato-oester May 1, 2022
d906284
Revert "Continued frontend implementation for personal log. Refresh o…
renato-oester May 1, 2022
855d3ec
Revert "Started frontend implementation of Log butten/page"
renato-oester May 1, 2022
98f469f
Revert " add translation"
renato-oester May 1, 2022
d5875d5
Revert " add translation for Log"
renato-oester May 1, 2022
d80c71c
Creates encryptables filtered_list presenter to handle parameters pas…
renato-oester May 1, 2022
9be00db
fixes rubocop warnings
renato-oester May 1, 2022
7caaecb
Adds versions and corresponding encryptable fixtures to test database…
renato-oester May 1, 2022
3777687
Adds system/controller specs for recent Credentials
renato-oester May 2, 2022
f060679
starts implementing filter_by_query functionality for encryptables
renato-oester May 2, 2022
12626ba
completes filter_by_query functionality and specs for encryptables
renato-oester May 2, 2022
92f2ca3
fixes specs and fixtures
renato-oester May 2, 2022
7894fb7
Recent credential requests now only return valid encryptables
renato-oester May 2, 2022
86f8ca5
fixes encryptables_controller_system_spec.rb
renato-oester May 2, 2022
a0b198c
Fixes specs
renato-oester May 2, 2022
1a64bea
Cleanup recent credentials fetching
Robin481 May 2, 2022
a268bf3
Merge branch '572-LOG-recent-credentials-on-dashboard' of github.com:…
Robin481 May 2, 2022
3cca724
Fix rubocop complaint
Robin481 May 3, 2022
328d4be
Changes the handling of request parameters
renato-oester May 5, 2022
e55127a
Removes some fixtures and fixes related specs
renato-oester May 5, 2022
ff8d3bf
fixes recent Credentials specs by creating encryptables/logs during t…
renato-oester May 6, 2022
7e5a07f
code cleanup
renato-oester May 6, 2022
5d8caeb
extends controller specs for recent credentials functionality
renato-oester May 9, 2022
61369fe
fixes system specs
renato-oester May 10, 2022
36cce10
Merge branch 'master' into 572-LOG-recent-credentials-on-dashboard
renato-oester May 10, 2022
01d47ef
fixes rubocop errors
renato-oester May 10, 2022
0f99759
resolves merge conflicts
renato-oester May 10, 2022
f850747
removes remains from merge conflict
renato-oester May 10, 2022
1ce6880
pressed backspace once
renato-oester May 12, 2022
bb89cc5
Merge branch '564-LOG_encryptable_read_access' into 572-LOG-recent-cr…
renato-oester May 18, 2022
4622b01
change spelling in specs
renato-oester May 18, 2022
1508e17
add method true? to evaluate params
renato-oester May 18, 2022
78971f2
rewrite variable in camel_case
renato-oester May 18, 2022
2f54b21
move method true? to base class filtered_list
renato-oester May 18, 2022
1d729c1
include encryptables when loading logs
renato-oester May 18, 2022
df28b42
extend includes to also include folders
renato-oester May 18, 2022
130e5c8
change fabricated credentials
renato-oester May 18, 2022
d323c2c
Merge branch '564-LOG_encryptable_read_access' into 572-LOG-recent-cr…
renato-oester May 18, 2022
b5f4daf
fix error from merge conflict
renato-oester May 18, 2022
9ab5e35
fix rubocop errors
renato-oester May 18, 2022
580ed23
fix encryptables controller spec
renato-oester May 18, 2022
0a9ddc4
change method fetch_entries to work with encryptable_file lookup
renato-oester May 18, 2022
47de094
create method log_read_access to create logs instead of touch
renato-oester May 18, 2022
777fc7d
fix rubocop errors
renato-oester May 18, 2022
d13773e
Merge branch '564-LOG_encryptable_read_access' into 572-LOG-recent-cr…
renato-oester May 18, 2022
9b639e0
correct spelling and fill in mariana trench
renato-oester May 20, 2022
e0a209c
rework fetch_entries method
renato-oester May 22, 2022
8816bd3
fix fetch_entries method
renato-oester May 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/controllers/api/encryptables_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ def model_class
end
# rubocop:enable Metrics/MethodLength

def fetch_entries
if encryptable_file?
super
elsif tag_param.present?
user_encryptables.find_by(tag: tag_param)
else
Encryptables::FilteredList.new(current_user, params).fetch_entries
end
end

def build_entry
return build_encryptable_file if encryptable_file?

Expand Down
49 changes: 49 additions & 0 deletions app/presenters/encryptables/filtered_list.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# frozen_string_literal: true

module ::Encryptables
class FilteredList < ::FilteredList

def fetch_entries
filtered_encryptables = encryptables

filtered_encryptables = filter_by_recent if recent?
filtered_encryptables = filter_by_query(filtered_encryptables) if query


filtered_encryptables
end

private

def query
@params[:q]&.strip&.downcase
end

def recent?
true?(@params[:recent])
end

def encryptables
@current_user.encryptables
end

def filter_by_query(encryptables)
encryptables.where(
'lower(encryptables.description) LIKE :query
OR lower(encryptables.name) LIKE :query',
query: "%#{query}%"
)
end

def filter_by_recent
Version
.includes(:encryptable, encryptable: [:folder])
.where(whodunnit: @current_user)
.order(created_at: :desc)
.group(:item_id, :item_type)
.select(:item_id, :item_type)
.limit(5)
.map(&:encryptable)
end
end
end
4 changes: 4 additions & 0 deletions app/presenters/filtered_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ def fetch_entries
def list_param(key)
@params[key].to_a.map(&:to_i)
end

def true?(value)
%w[1 yes true].include?(value.to_s.downcase)
end
end
15 changes: 12 additions & 3 deletions frontend/app/routes/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,31 @@ export default class DashboardRoute extends BaseRoute {
};

async model(params) {
params["limit"] = 20;
const favouriteTeams = await this.getFavouriteTeams(params);
const teams = this.getTeams(params);
const teams = await this.getTeams(params);
const recentCredentials = await this.getRecentCredentials(params);

return RSVP.hash({
favouriteTeams,
teams
teams,
recentCredentials
});
}

async getFavouriteTeams(params) {
params["limit"] = 20;
params["favourite"] = true;
return await this.store.query("team", params);
}

async getTeams(params) {
params["limit"] = 20;
params["favourite"] = false;
return await this.store.query("team", params);
}

async getRecentCredentials(params) {
params["recent"] = true;
return await this.store.query("encryptable", params);
}
}
4 changes: 2 additions & 2 deletions frontend/app/templates/components/dashboard-card.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
</svg>
</div>

<h1 class="header">{{this.team.name}}</h1>
</div>
<h1 class="header">{{this.content.name}}</h1>
</div>
16 changes: 14 additions & 2 deletions frontend/app/templates/dashboard.hbs
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
<div class="dashboard-grid-container">
{{#if @model.recentCredentials}}
<h3 class="primary-header">Recent Credentials</h3>
<div class="primary-content">
{{#each this.model.recentCredentials as |encryptable|}}
<a href="/encryptables/{{encryptable.id}}">
<DashboardCard @content={{encryptable}} />
</a>
{{/each}}
</div>
{{/if}}

{{#if @model.favouriteTeams}}
<h3 class="primary-header">Favourites</h3>
<div class="primary-content">
{{#each this.model.favouriteTeams as |team|}}
<a href="/teams/{{team.id}}">
<DashboardCard @team={{team}} />
<DashboardCard @content={{team}} />
</a>
{{/each}}
</div>
{{/if}}

{{#if this.model.teams}}
<h3 class="primary-header">Teams</h3>
<div class="primary-content">
{{#each this.model.teams as |team|}}
<a href="/teams/{{team.id}}">
<DashboardCard @team={{team}} />
<DashboardCard @content={{team}} />
</a>
{{/each}}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module("Integration | Component | dashboard-card", function (hooks) {

// Template block usage:
await render(hbs`
<DashboardCard @team={{this.team}}>
<DashboardCard @content={{this.team}}>
</DashboardCard>
`);

Expand Down
94 changes: 92 additions & 2 deletions spec/controllers/api/encryptables_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

get :index, params: { 'q': 'Personal' }, xhr: true

credentials1_json = data.second
expect(data.count).to eq 1
credentials1_json = data.first
credentials1_json_attributes = credentials1_json['attributes']
credentials1_json_relationships = credentials1_json['relationships']

Expand All @@ -37,7 +38,7 @@
expect_json_object_includes_keys(credentials1_json_relationships, nested_models)
end

it 'returns all enncryptables if empty query param given' do
it 'returns all encryptables if empty query param given' do
login_as(:alice)

get :index, params: { 'q': '' }, xhr: true
Expand Down Expand Up @@ -129,6 +130,87 @@

expect(response.status).to eq(403)
end

context 'recent Credentials' do
let!(:recent_credentials) do
folder = teams(:team1).folders.first
private_key = decrypt_private_key(bob)
team_password = folder.team.decrypt_team_password(bob, private_key)
Fabricate.times(
6,
:credential,
folder: folder,
team_password: team_password
)
end

it 'returns most recent credentials' do
login_as(:alice)

recent_credentials.each do |credential|
log_read_access(alice.id, credential)
end

get :index, params: { recent: true }, xhr: true

expect(response.status).to be(200)
expect(data.size).to eq(5)
attributes = data.first['attributes']
expect(attributes['name']).to eq recent_credentials.last.name
expect(attributes['description']).to eq recent_credentials.last.description
end

it 'shows most recently used credential first in list' do
login_as(:alice)


recent_credentials.each do |credential|
log_read_access(alice.id, credential)
end
log_read_access(alice.id, credentials1)

get :index, params: { recent: true }, xhr: true

expect(response.status).to be(200)
expect(data.size).to eq(5)
attributes = data.first['attributes']
expect(attributes['name']).to eq credentials1.name
expect(attributes['description']).to eq credentials1.description

end
it 'does not show credentials with no access' do
login_as(:bob)

recent_credentials1 = recent_credentials.first
log_read_access(alice.id, recent_credentials1)

get :index, params: { recent: true }, xhr: true

expect(response.status).to be(200)
expect(data.size).to eq(0)
end

it 'does not show deleted credentials' do
login_as(:alice)

recent_credentials1 = recent_credentials.first
log_read_access(alice.id, recent_credentials1)

get :index, params: { recent: true }, xhr: true

expect(data.size).to eq(1)
attributes = data.first['attributes']
expect(attributes['name']).to eq recent_credentials1.name
expect(attributes['description']).to eq recent_credentials1.description

recent_credentials1.destroy!

get :index, params: { recent: true }, xhr: true

expect(response.status).to be(200)
expect(data.size).to eq(0)
end
end
end

context 'GET show' do
Expand Down Expand Up @@ -777,4 +859,12 @@ def set_auth_headers
request.headers['Authorization-User'] = bob.username
request.headers['Authorization-Password'] = Base64.encode64('password')
end

def log_read_access(user_id, credential)
v = credential.paper_trail.save_with_version
v.whodunnit = user_id
v.event = :viewed
v.created_at = DateTime.now
v.save!
end
end
2 changes: 1 addition & 1 deletion spec/fabricators/encryptables/credentials_fabricator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

Fabricator(:credential, from: 'Encryptable::Credentials') do
transient :team_password
name { Faker::Team.creature }
name { sequence(:name) { |i| Faker::Team.creature + " #{i}" } }
cleartext_username { Faker::Internet.user_name }
cleartext_password { Faker::Internet.password }
before_save do |account, attrs|
Expand Down
37 changes: 31 additions & 6 deletions spec/system/dashboard_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,55 @@
describe 'Dashboard', type: :system, js: true do
include SystemHelpers

let(:credentials) { encryptables(:credentials1) }
let(:team) { teams(:team1) }


it 'renders dashboard grid' do
login_as_user(:alice)
visit("/encryptables/#{credentials.id}")
visit('/dashboard')

expect(page.current_path).to eq('/dashboard')

expect(page).to have_selector('pzsh-hero', visible: true)
expect(page).to have_selector('pzsh-banner', visible: true)
expect(page).to have_text('Recent Credentials', count: 1)
expect(page).to have_text('Favourites', count: 1)
expect(page).to have_text('Teams', count: 1)

expect(page).not_to have_selector 'div.content'

expect(page).to have_selector('div.dashboard-grid-card', count: 3)
expect(page).to have_selector('div.primary-content', count: 3)
end

it 'navigates to team on team card click' do
login_as_user(:alice)
visit("/encryptables/#{credentials.id}")
visit('/dashboard')


expect(page.current_path).to eq('/dashboard')

expect(page).to have_selector('pzsh-hero', visible: true)
all('div.dashboard-grid-card').first.click

expect(page.current_path).to eq('/teams/235930340')
first('div.dashboard-grid-card', text: team.name).click

expect(page.current_path).to eq("/teams/#{team.id}")
expect(page).to have_selector 'div.content'
end

it 'lists recently accessed encryptable' do
login_as_user(:alice)
visit("/encryptables/#{credentials.id}")
visit('/dashboard')


expect(page.current_path).to eq('/dashboard')

expect(page).to have_selector('pzsh-hero', visible: true)

first('div.dashboard-grid-card', text: credentials.name).click

expect(page.current_path).to eq("/encryptables/#{credentials.id}")
expect(page).to have_selector 'div.content'
end

end