Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(core): move kratos e2e tests and delete e2e dir #3943

Merged
merged 21 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
1cb8283
refactor(core): move 'getNextPageToken' function
vindard Feb 5, 2024
8eac77d
test(core): setup initial auth integration test
vindard Feb 5, 2024
e81cf02
test(core): move more kratos tests to integration
vindard Feb 5, 2024
591e425
test(core): move device-account tests to integration
vindard Feb 6, 2024
c7298f2
chore(core): delete e2e dir
vindard Feb 6, 2024
639a2e9
chore(core): delete unused mocks
vindard Feb 6, 2024
6aa5fcb
chore(core): cleanup unused 'bitcoin-core' helpers
vindard Feb 6, 2024
06a14ae
chore(core): cleanup unused 'bitcoind' helpers
vindard Feb 6, 2024
bc0caba
chore(core): cleanup unused 'bria' helpers
vindard Feb 6, 2024
8d2c0bb
chore(core): cleanup unused 'check-is-balanced' helpers
vindard Feb 6, 2024
eb864ab
chore(core): cleanup unused 'index' helpers
vindard Feb 6, 2024
9625f24
chore(core): cleanup unused 'kratos' helpers
vindard Feb 6, 2024
3d61434
chore(core): cleanup unused 'ledger' helpers
vindard Feb 6, 2024
5d701c7
chore(core): cleanup unused 'lightning' helpers
vindard Feb 6, 2024
3b78375
chore(core): cleanup unused 'rate-limit' helpers
vindard Feb 6, 2024
7f52e18
chore(core): cleanup unused 'redis' helpers
vindard Feb 6, 2024
b756780
chore(core): cleanup unused 'shared' helpers
vindard Feb 6, 2024
b9fdd04
chore(core): cleanup unused 'signer-wallet' helpers
vindard Feb 6, 2024
e282bb9
chore(core): cleanup unused 'user' helpers
vindard Feb 6, 2024
99d1594
chore(core): cleanup unused 'wallet' helpers
vindard Feb 6, 2024
ca20f97
refactor: move 'getNextPageToken' to services layer
vindard Feb 7, 2024
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
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export LOG_LEVEL="info"

export KRATOS_MASTER_USER_PASSWORD="passwordHardtoFindWithNumber123"
export KRATOS_PG_HOST="localhost"
export KRATOS_PG_PORT="5433"
export KRATOS_PG_PORT="5432"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont see changes in docker compose.. are you sure about this?

Copy link
Contributor Author

@vindard vindard Feb 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, this assumes we now target tilt deps and not docker-compose deps anymore. It's probably irrelevant since we're planning to find a way to remove .env and have all the things we would normally need for local dev come through buck either way.

We have some cleaning up of docs, deps, envs and local workflows to do after this PR


export OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4318"
# TODO: rename to OTEL_SERVICE_NAME
Expand All @@ -96,7 +96,7 @@ export TRACING_SERVICE_NAME="galoy-dev"

export MATTERMOST_WEBHOOK_URL="https://chat.galoy.io/hooks/sometoken"

export KRATOS_PG_CON="postgres://dbuser:secret@localhost:5433/default?sslmode=disable"
export KRATOS_PG_CON="postgres://dbuser:secret@localhost:5432/default?sslmode=disable"

export UNSECURE_DEFAULT_LOGIN_CODE="000000"
export UNSECURE_IP_FROM_REQUEST_OBJECT=true
Expand Down
4 changes: 2 additions & 2 deletions core/api/.env
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export LOG_LEVEL="info"
export KRATOS_MASTER_USER_PASSWORD="passwordHardtoFindWithNumber123"
export KRATOS_ADMIN_URL="http://localhost:4434"
export KRATOS_PG_HOST="localhost"
export KRATOS_PG_PORT="5433"
export KRATOS_PG_PORT="5432"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


export OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4318"
# TODO: rename to OTEL_SERVICE_NAME
Expand All @@ -97,7 +97,7 @@ export TRACING_SERVICE_NAME="galoy-dev"

export MATTERMOST_WEBHOOK_URL="https://chat.galoy.io/hooks/sometoken"

export KRATOS_PG_CON="postgres://dbuser:secret@localhost:5433/default?sslmode=disable"
export KRATOS_PG_CON="postgres://dbuser:secret@localhost:5432/default?sslmode=disable"

export UNSECURE_DEFAULT_LOGIN_CODE="000000"
export UNSECURE_IP_FROM_REQUEST_OBJECT=true
Expand Down
20 changes: 19 additions & 1 deletion core/api/src/domain/authentication/index.types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,39 @@ type IdentityPhone = IdentityBase & {
phone: PhoneNumber
email: undefined
emailVerified: undefined

username?: undefined
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe I am missing something but kratos is not updated when the user sets the username.. so do we have a process syncing this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is different. It's added to IdentityPhone/IdentityEmail/IdentityPhoneEmail just to satisfy the AnyIdentity interface and it really only has meaning in IdentityDeviceAccount where the type is IdentityUsername and not our user's account usernames

}

type IdentityEmail = IdentityBase & {
phone: undefined
email: EmailAddress
emailVerified: boolean

username?: undefined
}

type IdentityPhoneEmail = IdentityBase & {
phone: PhoneNumber
email: EmailAddress
emailVerified: boolean

username?: undefined
}

type IdentityDeviceAccount = IdentityBase & {
username: IdentityUsername

phone?: undefined
email?: undefined
emailVerified?: undefined
}

type AnyIdentity = IdentityPhone | IdentityEmail | IdentityPhoneEmail
type AnyIdentity =
| IdentityPhone
| IdentityEmail
| IdentityPhoneEmail
| IdentityDeviceAccount

type Session = {
identity: AnyIdentity
Expand Down
28 changes: 14 additions & 14 deletions core/api/src/services/kratos/identity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ import { getKratosPostgres, kratosAdmin, toDomainIdentity } from "./private"
import { IdentifierNotFoundError } from "@/domain/authentication/errors"
import { ErrorLevel } from "@/domain/shared"

export const getNextPageToken = (link: string): string | undefined => {
const links = link.split(",")
const nextLink = links.find((link) => link.includes('rel="next"'))

if (nextLink) {
const matches = nextLink.match(/page_token=([^;&>]+)/)
if (matches) {
return matches[1]
}
}

return undefined
}

export const IdentityRepository = (): IIdentityRepository => {
const getIdentity = async (
kratosUserId: UserId,
Expand Down Expand Up @@ -109,17 +123,3 @@ export const IdentityRepository = (): IIdentityRepository => {
getUserIdFromFlowId,
}
}

export const getNextPageToken = (link: string): string | undefined => {
const links = link.split(",")
const nextLink = links.find((link) => link.includes('rel="next"'))

if (nextLink) {
const matches = nextLink.match(/page_token=([^;&>]+)/)
if (matches) {
return matches[1]
}
}

return undefined
}
8 changes: 8 additions & 0 deletions core/api/src/services/kratos/private.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,12 @@ export const toDomainIdentity = (identity: KratosIdentity): AnyIdentity => {
createdAt = new Date()
}

const { username: rawUsername } = identity.traits
return {
id: identity.id as UserId,
phone: identity.traits.phone as PhoneNumber,
email: identity.traits.email as EmailAddress,
username: rawUsername !== undefined ? (rawUsername as IdentityUsername) : rawUsername,
emailVerified: identity.verifiable_addresses?.[0].verified ?? false,
totpEnabled: identity?.credentials?.totp?.type === "totp",
schema: toSchema(identity.schema_id),
Expand All @@ -98,10 +100,12 @@ export const toDomainIdentityEmail = (identity: KratosIdentity): IdentityEmail =
createdAt = new Date()
}

const { username: rawUsername } = identity.traits
return {
id: identity.id as UserId,
phone: undefined,
email: identity.traits.email as EmailAddress,
username: rawUsername !== undefined ? (rawUsername as IdentityUsername) : rawUsername,
emailVerified: identity.verifiable_addresses?.[0].verified ?? false,
totpEnabled: identity?.credentials?.totp?.type === "totp",
schema: toSchema(identity.schema_id),
Expand All @@ -123,10 +127,12 @@ export const toDomainIdentityPhone = (identity: KratosIdentity): IdentityPhone =
createdAt = new Date()
}

const { username: rawUsername } = identity.traits
return {
id: identity.id as UserId,
phone: identity.traits.phone as PhoneNumber,
email: undefined,
username: rawUsername !== undefined ? (rawUsername as IdentityUsername) : rawUsername,
emailVerified: undefined,
totpEnabled: identity?.credentials?.totp?.type === "totp",
schema: toSchema(identity.schema_id),
Expand All @@ -150,10 +156,12 @@ export const toDomainIdentityEmailPhone = (
createdAt = new Date()
}

const { username: rawUsername } = identity.traits
return {
id: identity.id as UserId,
phone: identity.traits.phone as PhoneNumber,
email: identity.traits.email as EmailAddress,
username: rawUsername !== undefined ? (rawUsername as IdentityUsername) : rawUsername,
emailVerified: identity.verifiable_addresses?.[0].verified ?? false,
totpEnabled: identity?.credentials?.totp?.type === "totp",
schema: toSchema(identity.schema_id),
Expand Down
27 changes: 0 additions & 27 deletions core/api/test/e2e/jest.config.js

This file was deleted.

26 changes: 0 additions & 26 deletions core/api/test/e2e/jest.setup.js

This file was deleted.

1 change: 0 additions & 1 deletion core/api/test/e2e/servers/index.types.d.ts

This file was deleted.

Loading
Loading