Skip to content

Commit

Permalink
fix: ConfirmLoginSession, missing FKs; add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
grantzvolsky authored and aeneasr committed Sep 7, 2022
1 parent c56b958 commit 1f7bf40
Show file tree
Hide file tree
Showing 221 changed files with 1,973 additions and 397 deletions.
2 changes: 1 addition & 1 deletion consent/manager_test_helpers.go
Expand Up @@ -302,7 +302,7 @@ func TestHelperNID(t1ClientManager client.Manager, t1ValidNID Manager, t2Invalid
require.Error(t, err)
_, err = t1ValidNID.HandleLoginRequest(context.Background(), testLR.ID, &testHLR)
require.NoError(t, err)
require.Error(t, t2InvalidNID.ConfirmLoginSession(context.Background(), testLS.ID, time.Now(), testLS.Subject, true))
require.NoError(t, t2InvalidNID.ConfirmLoginSession(context.Background(), testLS.ID, time.Now(), testLS.Subject, true))
require.NoError(t, t1ValidNID.ConfirmLoginSession(context.Background(), testLS.ID, time.Now(), testLS.Subject, true))
require.Error(t, t2InvalidNID.DeleteLoginSession(context.Background(), testLS.ID))
require.NoError(t, t1ValidNID.DeleteLoginSession(context.Background(), testLS.ID))
Expand Down
8 changes: 5 additions & 3 deletions go.mod
Expand Up @@ -6,6 +6,7 @@ replace (
github.com/bradleyjkemp/cupaloy/v2 => github.com/aeneasr/cupaloy/v2 v2.6.1-0.20210924214125-3dfdd01210a3
github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.0.0
github.com/gobuffalo/packr => github.com/gobuffalo/packr v1.30.1
github.com/gobuffalo/pop/v6 => github.com/gobuffalo/pop/v6 v6.0.2-alpha-ci.0.20220421231416-e6ba76ba3be3
github.com/gogo/protobuf => github.com/gogo/protobuf v1.3.2
github.com/luna-duclos/instrumentedsql => github.com/ory/instrumentedsql v1.2.0
github.com/luna-duclos/instrumentedsql/opentracing => github.com/ory/instrumentedsql/opentracing v0.0.0-20210903114257-c8963b546c5c
Expand All @@ -31,7 +32,7 @@ require (
github.com/gobuffalo/pop/v6 v6.0.1
github.com/gobuffalo/x v0.0.0-20181007152206-913e47c59ca7
github.com/gobwas/glob v0.2.3
github.com/gofrs/uuid v4.1.0+incompatible
github.com/gofrs/uuid v4.2.0+incompatible
github.com/golang/mock v1.6.0
github.com/google/uuid v1.3.0
github.com/gorilla/securecookie v1.1.1
Expand All @@ -40,7 +41,7 @@ require (
github.com/gtank/cryptopasta v0.0.0-20170601214702-1f550f6f2f69
github.com/hashicorp/go-cleanhttp v0.5.2
github.com/instana/testify v1.6.2-0.20200721153833-94b1851f4d65
github.com/jackc/pgx/v4 v4.13.0
github.com/jackc/pgx/v4 v4.15.0
github.com/jmoiron/sqlx v1.3.4
github.com/julienschmidt/httprouter v1.3.0
github.com/luna-duclos/instrumentedsql v1.1.3
Expand All @@ -67,8 +68,9 @@ require (
github.com/sirupsen/logrus v1.8.1
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/cobra v1.4.0
github.com/stretchr/testify v1.7.0
github.com/stretchr/testify v1.7.1
github.com/tidwall/gjson v1.14.1
github.com/stretchr/testify v1.7.0
github.com/tidwall/sjson v1.2.4
github.com/toqueteos/webbrowser v1.2.0
github.com/urfave/negroni v1.0.0
Expand Down
44 changes: 22 additions & 22 deletions go.sum

Large diffs are not rendered by default.

@@ -1,5 +1,5 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen
CREATE TABLE hydra_oauth2_flow
(
login_challenge character varying(40) NOT NULL,
Expand Down
@@ -1,3 +1,3 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen
-- Down migrations from Hydra 2.x to 1.x are not available.
@@ -1,5 +1,5 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen
CREATE TABLE hydra_oauth2_flow
(
`login_challenge` varchar(40) NOT NULL,
Expand All @@ -10,7 +10,7 @@ CREATE TABLE hydra_oauth2_flow
`request_url` text NOT NULL,
`login_skip` tinyint(1) NOT NULL,
`client_id` varchar(255) NOT NULL,
`requested_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`requested_at` timestamp NOT NULL DEFAULT now(),
`login_initialized_at` timestamp NULL DEFAULT NULL,
`oidc_context` text NOT NULL,
`login_session_id` varchar(40),
Expand Down
@@ -1,5 +1,5 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen
CREATE TABLE hydra_oauth2_flow
(
login_challenge character varying(40) NOT NULL,
Expand Down
@@ -1,5 +1,5 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen
CREATE TABLE hydra_oauth2_flow
(
login_challenge VARCHAR(40) NOT NULL PRIMARY KEY,
Expand Down
@@ -1,5 +1,5 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

INSERT INTO hydra_oauth2_flow (
state,
Expand Down
@@ -1,5 +1,5 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

INSERT INTO hydra_oauth2_flow (
state,
Expand Down
@@ -1,5 +1,5 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

INSERT INTO hydra_oauth2_flow (
state,
Expand Down
@@ -1,5 +1,5 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

INSERT INTO hydra_oauth2_flow (
state,
Expand Down
@@ -1,5 +1,5 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

CREATE INDEX hydra_oauth2_flow_client_id_subject_idx ON public.hydra_oauth2_flow USING btree (client_id, subject);
CREATE INDEX hydra_oauth2_flow_cid_idx ON public.hydra_oauth2_flow USING btree (client_id);
Expand Down
@@ -1,4 +1,4 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

ALTER TABLE hydra_oauth2_access DROP FOREIGN KEY hydra_oauth2_access_challenge_id_fk;
@@ -1,5 +1,5 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

CREATE INDEX hydra_oauth2_flow_client_id_subject_idx ON public.hydra_oauth2_flow USING btree (client_id, subject);
CREATE INDEX hydra_oauth2_flow_cid_idx ON public.hydra_oauth2_flow USING btree (client_id);
Expand Down
@@ -1,4 +1,4 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

CREATE INDEX hydra_oauth2_flow_client_id_idx ON hydra_oauth2_flow (client_id);
@@ -1,4 +1,4 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

ALTER TABLE ONLY public.hydra_oauth2_flow ADD CONSTRAINT hydra_oauth2_flow_pkey PRIMARY KEY (login_challenge);
@@ -1,5 +1,5 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

ALTER TABLE hydra_oauth2_access ADD CONSTRAINT hydra_oauth2_access_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE;

@@ -1,4 +1,4 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

DROP TABLE hydra_oauth2_consent_request_handled;
@@ -1,4 +1,4 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

CREATE INDEX hydra_oauth2_flow_login_session_id_idx ON hydra_oauth2_flow (login_session_id);
@@ -1,5 +1,5 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

ALTER TABLE ONLY public.hydra_oauth2_flow ADD CONSTRAINT hydra_oauth2_flow_client_id_fk FOREIGN KEY (client_id) REFERENCES public.hydra_client(id) ON DELETE CASCADE;
ALTER TABLE ONLY public.hydra_oauth2_flow ADD CONSTRAINT hydra_oauth2_flow_login_session_id_fk FOREIGN KEY (login_session_id) REFERENCES public.hydra_oauth2_authentication_session(id) ON DELETE CASCADE;
Expand Down
@@ -1,4 +1,4 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

ALTER TABLE hydra_oauth2_code DROP FOREIGN KEY hydra_oauth2_code_challenge_id_fk;
@@ -1,4 +1,4 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

DROP TABLE hydra_oauth2_consent_request;
@@ -1,4 +1,4 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

CREATE INDEX hydra_oauth2_flow_subject_idx ON hydra_oauth2_flow (subject);
@@ -1,4 +1,4 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

DROP TABLE hydra_oauth2_consent_request_handled;
@@ -1,5 +1,5 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

ALTER TABLE hydra_oauth2_code ADD CONSTRAINT hydra_oauth2_code_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE;

@@ -1,4 +1,4 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

DROP TABLE hydra_oauth2_authentication_request_handled;
@@ -1,4 +1,4 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

CREATE UNIQUE INDEX hydra_oauth2_flow_consent_challenge_id_idx ON hydra_oauth2_flow (consent_challenge_id);
@@ -1,4 +1,4 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

DROP TABLE hydra_oauth2_consent_request;
@@ -1,4 +1,4 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

ALTER TABLE hydra_oauth2_oidc DROP FOREIGN KEY hydra_oauth2_oidc_challenge_id_fk;
@@ -1,4 +1,4 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

DROP TABLE hydra_oauth2_authentication_request;
@@ -1,4 +1,4 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

CREATE UNIQUE INDEX hydra_oauth2_flow_login_verifier_idx ON hydra_oauth2_flow (login_verifier);
@@ -1,4 +1,4 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

DROP TABLE hydra_oauth2_authentication_request_handled;
@@ -1,5 +1,5 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

ALTER TABLE hydra_oauth2_oidc ADD CONSTRAINT hydra_oauth2_oidc_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE;

@@ -1,5 +1,5 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

CREATE INDEX hydra_oauth2_flow_consent_verifier_idx ON hydra_oauth2_flow (consent_verifier);

@@ -1,4 +1,4 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

DROP TABLE hydra_oauth2_authentication_request;
@@ -1,4 +1,4 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

ALTER TABLE hydra_oauth2_pkce DROP FOREIGN KEY hydra_oauth2_pkce_challenge_id_fk;
@@ -1,4 +1,4 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

DROP TABLE hydra_oauth2_authentication_request;
@@ -1,5 +1,5 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

ALTER TABLE hydra_oauth2_pkce ADD CONSTRAINT hydra_oauth2_pkce_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE;

@@ -1,4 +1,4 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

DROP TABLE hydra_oauth2_authentication_request_handled;
@@ -1,4 +1,4 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

ALTER TABLE hydra_oauth2_refresh DROP FOREIGN KEY hydra_oauth2_refresh_challenge_id_fk;
@@ -1,4 +1,4 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

DROP TABLE hydra_oauth2_consent_request;
@@ -1,5 +1,5 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

ALTER TABLE hydra_oauth2_refresh ADD CONSTRAINT hydra_oauth2_refresh_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE;

@@ -1,5 +1,5 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

DROP TABLE hydra_oauth2_consent_request_handled;

Expand Down
@@ -1,4 +1,4 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

DROP TABLE hydra_oauth2_consent_request_handled;
@@ -1,4 +1,4 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

DROP TABLE hydra_oauth2_code;
@@ -1,4 +1,4 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

DROP TABLE hydra_oauth2_consent_request;
@@ -1,5 +1,5 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

CREATE TABLE hydra_oauth2_code
(
Expand Down
@@ -1,4 +1,4 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

DROP TABLE hydra_oauth2_authentication_request_handled;
@@ -1,4 +1,4 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

CREATE INDEX hydra_oauth2_code_client_id_idx ON hydra_oauth2_code (client_id);
@@ -1,4 +1,4 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

DROP TABLE hydra_oauth2_authentication_request;
@@ -1,4 +1,4 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

CREATE INDEX hydra_oauth2_code_challenge_id_idx ON hydra_oauth2_code (challenge_id);
@@ -1,5 +1,5 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

CREATE INDEX hydra_oauth2_code_request_id_idx ON hydra_oauth2_code (request_id);

Expand Down
@@ -1,4 +1,4 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

DROP TABLE hydra_oauth2_oidc;
@@ -1,5 +1,5 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

CREATE TABLE hydra_oauth2_oidc
(
Expand Down
@@ -1,4 +1,4 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

CREATE INDEX hydra_oauth2_oidc_client_id_idx ON hydra_oauth2_oidc (client_id);
@@ -1,4 +1,4 @@
-- Migration generated by the command below; DO NOT EDIT.
-- hydra:generate hydra migrations gen
-- hydra:generate hydra migrate gen

CREATE INDEX hydra_oauth2_oidc_challenge_id_idx ON hydra_oauth2_oidc (challenge_id);

0 comments on commit 1f7bf40

Please sign in to comment.