- Notifications
You must be signed in to change notification settings - Fork913
Commit3a243c1
authored
fix: remove shared mutable state between oidc tests (#17179)
Spotted on main:https://github.com/coder/coder/actions/runs/14179449567/job/39721999486```=== FAIL: coderd TestOIDCDomainErrorMessage/MalformedEmailErrorOmitsDomains (0.01s)==================WARNING: DATA RACERead at 0x00c060b54e68 by goroutine 296485: golang.org/x/oauth2.(*Config).Exchange() /home/runner/go/pkg/mod/golang.org/x/oauth2@v0.28.0/oauth2.go:228 +0x1d8 github.com/coder/coder/v2/coderd.(*OIDCConfig).Exchange() <autogenerated>:1 +0xb7 github.com/coder/coder/v2/coderd.New.func11.12.1.2.ExtractOAuth2.1.1() /home/runner/work/coder/coder/coderd/httpmw/oauth2.go:168 +0x7b5 net/http.HandlerFunc.ServeHTTP() /opt/hostedtoolcache/go/1.24.1/x64/src/net/http/server.go:2294 +0x47[...]Previous write at 0x00c060b54e68 by goroutine 55730: github.com/coder/coder/v2/coderd/coderdtest/oidctest.(*FakeIDP).SetRedirect() /home/runner/work/coder/coder/coderd/coderdtest/oidctest/idp.go:1280 +0x1e6 github.com/coder/coder/v2/coderd/coderdtest/oidctest.(*FakeIDP).LoginWithClient() /home/runner/work/coder/coder/coderd/coderdtest/oidctest/idp.go:494 +0x170 github.com/coder/coder/v2/coderd/coderdtest/oidctest.(*FakeIDP).AttemptLogin() /home/runner/work/coder/coder/coderd/coderdtest/oidctest/idp.go:479 +0x624 github.com/coder/coder/v2/coderd_test.TestOIDCDomainErrorMessage.func3() /home/runner/work/coder/coder/coderd/userauth_test.go:2041 +0x1f2```As seen, this race was caused by sharing a `*oidctest.FakeIDP` between test cases. The fix is to simply do the setup twice.```$ go test -race -run "TestOIDCDomainErrorMessage" github.com/coder/coder/v2/coderd -count=100ok github.com/coder/coder/v2/coderd 7.551s````1 parent7d08bf0 commit3a243c1
1 file changed
+19
-11
lines changedLines changed: 19 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1988 | 1988 |
| |
1989 | 1989 |
| |
1990 | 1990 |
| |
1991 |
| - | |
1992 |
| - | |
1993 | 1991 |
| |
1994 |
| - | |
1995 |
| - | |
1996 |
| - | |
1997 |
| - | |
1998 | 1992 |
| |
1999 |
| - | |
2000 |
| - | |
2001 |
| - | |
| 1993 | + | |
| 1994 | + | |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
| 1998 | + | |
| 1999 | + | |
| 2000 | + | |
| 2001 | + | |
| 2002 | + | |
| 2003 | + | |
| 2004 | + | |
| 2005 | + | |
2002 | 2006 |
| |
2003 | 2007 |
| |
2004 | 2008 |
| |
2005 | 2009 |
| |
2006 | 2010 |
| |
| 2011 | + | |
| 2012 | + | |
2007 | 2013 |
| |
2008 | 2014 |
| |
2009 | 2015 |
| |
2010 | 2016 |
| |
2011 | 2017 |
| |
2012 | 2018 |
| |
2013 | 2019 |
| |
2014 |
| - | |
| 2020 | + | |
2015 | 2021 |
| |
2016 | 2022 |
| |
2017 | 2023 |
| |
| |||
2031 | 2037 |
| |
2032 | 2038 |
| |
2033 | 2039 |
| |
| 2040 | + | |
| 2041 | + | |
2034 | 2042 |
| |
2035 | 2043 |
| |
2036 | 2044 |
| |
2037 | 2045 |
| |
2038 | 2046 |
| |
2039 | 2047 |
| |
2040 | 2048 |
| |
2041 |
| - | |
| 2049 | + | |
2042 | 2050 |
| |
2043 | 2051 |
| |
2044 | 2052 |
| |
|
0 commit comments
Comments
(0)