Skip to content

Instantly share code, notes, and snippets.

View blacksails's full-sized avatar

Benjamin Nørgaard blacksails

  • blacksails ApS
  • Aarhus, Denmark
View GitHub Profile
function dotfiles {
/usr/bin/git --git-dir=$HOME/.files/ --work-tree=$HOME $@
}
git clone --bare https://github.com/blacksails/dotfiles.git $HOME/.files
dotfiles checkout
if [ $? = 0 ]
then
echo "Checked out dotfiles."
else
echo "Backing up pre-existing dotfiles.";
kubectl config view --minify -o jsonpath='{.users[0].user.auth-provider.config.id-token}' | pbcopy

Keybase proof

I hereby claim:

  • I am blacksails on github.
  • I am blacksails (https://keybase.io/blacksails) on keybase.
  • I have a public key ASBFSG3s3HXZ6v8DKBbgA5mCCSHiTaygr9WGoySKhIp3fAo

To claim this, I am signing this object:

defmodule Avalonia.User do
use Avalonia.Web, :model
import Comeonin.Password, only: [strong_password?: 2]
import Comeonin.Bcrypt, only: [hashpwsalt: 1]
schema "users" do
field :email, :string
field :password, :string, virtual: true
field :password_digest, :string
Avalonia.AuthControllerTest
* logout should delete the session cookie (617.5ms)
* creates valid token and sets it in cookie (581.2ms)
* we get an error if the password does not match the password_digest (550.0ms)
* we get an error if the email is not found (1.2ms)
Finished in 1.9 seconds (0.1s on load, 1.7s on tests)
4 tests, 0 failures
@email "foo@bar.com"
@pw "Foobar12345!"
setup do
conn = conn() |> put_req_header("accept", "application/json")
{:ok, conn: conn}
end
test "creates valid token and sets it in cookie" do
changeset = User.changeset(%User{}, %{email: @email, password: @pw})
setup do
user = User.changeset(%User{}, %{
email: "foo@bar.com",
password: "Foobar12345!"})
|> Repo.insert!
role = Role.changeset(%Role{}, %{name: "some_role"})
|> Repo.insert!
{:ok, user: user, role: role}
end
# Test looks like this
test "call should set current_user to nil if auth fails" do
conn = post(conn, auth_path(conn, :login),
auth: %{@credentials | password: "cheesesticks"})
conn = VerifySession.call(conn, [])
refute conn.private.current_user
end
# This is what happens at the endpoint:
conn
iex(6)> VestasAPI.Repo.all assoc(p, :project_users)
** (Protocol.UndefinedError) protocol Ecto.Queryable not implemented for ProjectUser, the given module does not exist
(ecto) lib/ecto/queryable.ex:33: Ecto.Queryable.Atom.to_query/1
(ecto) lib/ecto/query/builder/from.ex:88: Ecto.Query.Builder.From.apply/2
(ecto) lib/ecto/association.ex:314: Ecto.Association.Has.assoc_query/2