Compare commits

...

4 Commits

Author SHA1 Message Date
Jamie Curnow
2145df0dfb
Use docker healthcheck for authentik 2024-11-13 10:28:02 +10:00
Jamie Curnow
331c761a1c
Wait for authentik to start in ci test 2024-11-13 08:51:24 +10:00
Jamie Curnow
03b3b6379b
Fix incorrect authentikm url in cypress test 2024-11-13 08:24:55 +10:00
Jamie Curnow
050c087a51
Fix annoying joqqueue issue where jobs were blocked by unused channel 2024-11-13 08:03:10 +10:00
8 changed files with 28 additions and 18 deletions

View File

@ -16,7 +16,7 @@ var (
func Start() {
ctx, cancel = context.WithCancel(context.Background())
q := &Queue{
jobs: make(chan Job, 10),
jobs: make(chan Job, 50),
ctx: ctx,
cancel: cancel,
}

View File

@ -17,7 +17,6 @@ type Queue struct {
type Job struct {
Name string
Action func() error // A function that should be executed when the job is running.
Done chan bool // A channel that should be closed when the job is done.
}
// AddJobs adds jobs to the queue and cancels channel.
@ -49,12 +48,5 @@ func (q *Queue) AddJob(job Job) {
// Run performs job execution.
func (j *Job) Run() error {
err := j.Action()
if err != nil {
j.Done <- true
return err
}
j.Done <- true
return nil
return j.Action()
}

View File

@ -77,6 +77,11 @@ docker-compose up -d --remove-orphans --pull=never fullstack
# wait for main container to be healthy
bash "$DIR/../wait-healthy" "$(docker-compose ps --all -q fullstack)" 120
# Wait for authentik to be healthy, if it exists as a compose service
if [ "$(docker-compose ps --all -q authentik)" != "" ]; then
bash "$DIR/../wait-healthy" "$(docker-compose ps --all -q authentik)" 90 'true'
fi
# Run tests
rm -rf "$DIR/../../test/results"
docker-compose up --build cypress

View File

@ -5,17 +5,24 @@ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [ "$1" == "" ]; then
echo "Waits for a docker container to be healthy."
echo "Usage: $0 docker-container 30"
echo " Usage: $0 docker-container 30"
echo "or use the third parameter to use the docker healthcheck instead of the internal one."
echo " Usage: $0 docker-container 30 true"
exit 1
fi
SERVICE=$1
LIMIT=${2:-90}
USE_DOCKER_HEALTHCHECK=${3:-false}
echo -e "${BLUE} ${CYAN}Waiting for healthy: ${YELLOW}${SERVICE}${RESET}"
is_up() {
docker exec "$SERVICE" /bin/healthcheck.sh
if [ "$USE_DOCKER_HEALTHCHECK" == "true" ]; then
docker inspect --format='{{.State.Health.Status}}' "$SERVICE" | grep -qi "healthy"
else
docker exec "$SERVICE" /bin/healthcheck.sh
fi
}
i=0

View File

@ -16,6 +16,9 @@ module.exports = defineConfig({
},
env: {
swaggerBase: '{{baseUrl}}/api/schema',
authentik: 'http://authentik:9000',
authentikLdap: 'authentik-ldap:3389',
oauthRedirect: 'http://fullstack:81',
},
baseUrl: 'http://localhost:1234',
},

View File

@ -15,6 +15,9 @@ module.exports = defineConfig({
},
env: {
swaggerBase: '{{baseUrl}}/api/schema',
authentik: 'http://authentik:9000',
authentikLdap: 'authentik-ldap:3389',
oauthRedirect: 'http://npm:81',
},
}
});

View File

@ -14,7 +14,7 @@ describe('LDAP with Authentik', () => {
path: '/api/settings/ldap-auth',
data: {
value: {
host: 'authentik-ldap:3389',
host: Cypress.env('authentik-ldap'),
base_dn: 'ou=users,DC=ldap,DC=goauthentik,DC=io',
user_dn: 'cn={{USERNAME}},ou=users,DC=ldap,DC=goauthentik,DC=io',
email_property: 'mail',

View File

@ -16,10 +16,10 @@ describe('OAuth with Authentik', () => {
value: {
client_id: 'U5gCy0ymU8OofWS4nmkAPugCbWkFkkPztap38ReD',
client_secret: '9ZFClxwp7LzbfhIDk7k9DngQNQfwDAYqPrQMGXjFumCvQZATtXCwme20o0TnLP6uEHUkKqEFOInhxp01gVeaHCLW83iTK4PonoUnpFnXgyZAcu0H3zBxxOkVtRwACaoW',
authorization_url: 'http://authentik-ldap:9000/application/o/authorize/',
resource_url: 'http://authentik-ldap:9000/application/o/userinfo/',
token_url: 'http://authentik-ldap:9000/application/o/token/',
logout_url: 'http://authentik-ldap:9000/application/o/npm3/end-session/',
authorization_url: Cypress.env('authentik') + '/application/o/authorize/',
resource_url: Cypress.env('authentik') + '/application/o/userinfo/',
token_url: Cypress.env('authentik') + '/application/o/token/',
logout_url: Cypress.env('authentik') + '/application/o/npm3/end-session/',
identifier: 'preferred_username',
scopes: [],
auto_create_user: true
@ -51,7 +51,7 @@ describe('OAuth with Authentik', () => {
it('Should log in with OAuth', function() {
cy.task('backendApiGet', {
token: token,
path: '/oauth/login?redirect_base=http%3A%2F%2Ffullstack%3A81',
path: '/oauth/login?redirect_base=' + encodeURI(Cypress.env('oauthRedirect')),
}).then((data) => {
expect(data).to.have.property('result');
cy.visit(data.result);