Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,9 @@ components:
description: Addresses associated with this entry
items:
$ref: '#/components/schemas/Address'
dummyPassword:
type: string
description: Example protected field
EntryPatch:
type: object
properties:
Expand All @@ -546,6 +549,9 @@ components:
type: string
nullable: true
minLength: 6
apiKey:
type: string
nullable: true
symbols:
type: array
nullable: true
Expand Down
70 changes: 37 additions & 33 deletions api/directory.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 19 additions & 13 deletions api/entries.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ func scanEntryRow(rows pgx.Rows) (Entry, int, error) {
description *string
contactName *string
email *string
dummyPassword *string
symbolsJSON [][]byte
endpointsJSON [][]byte
addressesJSON [][]byte
totalCount int
)

if err := rows.Scan(&id, &name, &description, &contactName, &email, &symbolsJSON, &endpointsJSON, &addressesJSON, &totalCount); err != nil {
if err := rows.Scan(&id, &name, &description, &contactName, &email, &dummyPassword, &symbolsJSON, &endpointsJSON, &addressesJSON, &totalCount); err != nil {
return Entry{}, 0, err
}

Expand Down Expand Up @@ -78,14 +79,15 @@ func scanEntryRow(rows pgx.Rows) (Entry, int, error) {
}

return Entry{
Id: &id,
Name: name,
Description: description,
ContactName: contactName,
Email: email,
Symbols: symbolsPtr,
Endpoints: endpointsPtr,
Addresses: addressesPtr,
Id: &id,
Name: name,
Description: description,
ContactName: contactName,
Email: email,
DummyPassword: dummyPassword,
Symbols: symbolsPtr,
Endpoints: endpointsPtr,
Addresses: addressesPtr,
}, totalCount, nil
}

Expand Down Expand Up @@ -121,6 +123,7 @@ func buildEntrySQL(whereClause string) string {
e.description,
e.contact_name,
e.email,
e.dummy_password,
ARRAY(SELECT row_to_json(s) FROM symbols s WHERE s.owner = e.id ORDER BY s.id) as symbols,
ARRAY(SELECT row_to_json(ep) FROM service_endpoints ep WHERE ep.entry = e.id ORDER BY ep.id) as endpoints,
ARRAY(
Expand Down Expand Up @@ -310,7 +313,9 @@ func (a ApiImpl) GetEntry(ctx context.Context, request GetEntryRequestObject) (G
}

func sanitizeEntry(entry *Entry) {
//do nada til we have some specifically sensitive fields
if entry.DummyPassword != nil {
*entry.DummyPassword = "<redacted>"
}
}

func (a ApiImpl) AddEntry(ctx context.Context, request AddEntryRequestObject) (AddEntryResponseObject, error) {
Expand All @@ -331,9 +336,10 @@ func (a ApiImpl) AddEntry(ctx context.Context, request AddEntryRequestObject) (A
qtx := a.queries.WithTx(tx)

toInsert := db.CreateEntryParams{
Name: request.Body.Name,
ContactName: request.Body.ContactName,
Email: request.Body.Email,
Name: request.Body.Name,
ContactName: request.Body.ContactName,
Email: request.Body.Email,
DummyPassword: request.Body.DummyPassword,
}
insertedEntry, err := qtx.CreateEntry(ctx, toInsert)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions db/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 30 additions & 17 deletions db/query.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion migrations/001_initial_schema.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ CREATE TABLE IF NOT EXISTS entries (
lms_location_code varchar(255),
contact_name varchar(255),
email varchar(255),
phone varchar(255)
phone varchar(255),
dummy_password varchar(255)
);

CREATE TABLE IF NOT EXISTS symbols (
Expand Down
7 changes: 4 additions & 3 deletions query.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ SELECT e.* FROM entries e, symbols s WHERE e.id = s.owner AND s.authority = @aut

-- name: CreateEntry :one
INSERT INTO entries (
name, contact_name, email
name, contact_name, email, dummy_password
) VALUES (
$1, $2, $3
$1, $2, $3, $4
)
RETURNING *;

Expand All @@ -21,7 +21,8 @@ SET
name = @name,
description = @description,
contact_name = @contact_name,
email = @email
email = @email,
dummy_password = @dummy_password
WHERE id = @id;

-- name: DeleteEntryById :exec
Expand Down
1 change: 1 addition & 0 deletions test/apifixtures/entries-limit-1-offset-1.get.res.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"id": "00000000-0000-0000-0000-000000000003",
"name": "Eine Weitere Einrichtung",
"contactName": "Klaus",
"dummyPassword":"<redacted>",
"addresses": [
"<<UNORDERED>>",
{
Expand Down
1 change: 1 addition & 0 deletions test/apifixtures/entries-limit-2.get.res.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"id": "00000000-0000-0000-0000-000000000003",
"name": "Eine Weitere Einrichtung",
"contactName": "Klaus",
"dummyPassword":"<redacted>",
"addresses": [
"<<UNORDERED>>",
{
Expand Down
1 change: 1 addition & 0 deletions test/apifixtures/entries.get.res.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"id": "00000000-0000-0000-0000-000000000003",
"name": "Eine Weitere Einrichtung",
"contactName": "Klaus",
"dummyPassword": "chicken_satellite_banana_penguin",
"addresses": [
"<<UNORDERED>>",
{
Expand Down
Loading
Loading