-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Persist credential with typed values (#1530)
* Insert credential body with properfield types * Add googlesheets schema for tests * Simplify params * Reuse change_credential * Apply typed body to update credentials * Cast credential body on worker fetch credential * Add changelog * Handle raw schema and unchanged schema on update * Add migration to update credential * Don't cast existing credentials on fetch credential * Add update_credential * Use testable migration * Fix warning * Add explicit test for returning saved credential * Add create test to check same cast as migrate * Liveview test creating a credential * Raw body updated with an integer
- Loading branch information
Showing
12 changed files
with
608 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
priv/repo/migrations/20231206115145_cast_credential_body.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
defmodule Lightning.Repo.Migrations.CastCredentialBody do | ||
use Ecto.Migration | ||
|
||
alias Lightning.Credentials | ||
alias Lightning.Credentials.Credential | ||
alias Lightning.Repo | ||
|
||
def change do | ||
[{Lightning.Vault, Application.get_env(:lightning, Lightning.Vault, [])}] | ||
|> Supervisor.start_link(strategy: :one_for_one) | ||
|
||
Repo.transaction(fn -> | ||
Credential | ||
|> Repo.all() | ||
|> Enum.each(&Credentials.migrate_credential_body/1) | ||
end) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$comment": "OAuth2", | ||
"properties": { | ||
"access_token": { | ||
"title": "Access Token", | ||
"type": "string", | ||
"description": "Your Google Sheets access token", | ||
"writeOnly": true, | ||
"minLength": 1, | ||
"examples": [ | ||
"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IjlGWERwYmZNRlQyU3ZRdVhoODQ2WVR3RUlCdyIsI" | ||
] | ||
} | ||
}, | ||
"type": "object", | ||
"additionalProperties": true, | ||
"required": ["access_token"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.