@@ -38,7 +38,7 @@ class Auth0Util(
38
38
private val auth = new AuthAPI (domain, managementApiClientId, managementApiClientSecret)
39
39
val api = new ManagementAPI (domain, requestManagementAPIToken())
40
40
41
- def createUser (): Auth0User = {
41
+ def createUser ()( implicit tc : TraceContext ) : Auth0User = {
42
42
val user = new User ()
43
43
val rand = new scala.util.Random
44
44
val password = s " ${rand.alphanumeric.take(20 ).mkString}${rand.nextInt()}"
@@ -48,11 +48,16 @@ class Auth0Util(
48
48
user.setEmail(email)
49
49
user.setVerifyEmail(false ) // avoid auth0 trying to send mails
50
50
user.setConnection(" Username-Password-Authentication" )
51
+ logger.debug(s " Creating user with username $username email $email and password $password" )
51
52
val id = executeManagementApiRequest(api.users().create(user)).getId
53
+ logger.debug(s " Created user ${email} with password ${password} (id: ${id}) " )
52
54
new Auth0User (id, email, password, this )
53
55
}
54
56
55
57
def deleteUser (id : String ): Unit = {
58
+ // Called from AutoCloseable.close, which doesn't propagate the trace context
59
+ implicit val traceContext : TraceContext = TraceContext .empty
60
+ logger.debug(s " Deleting user with id: ${id}" )
56
61
executeManagementApiRequest(api.users.delete(id))
57
62
}
58
63
@@ -70,7 +75,9 @@ class Auth0Util(
70
75
auth.requestToken(s " ${domain}/api/v2/ " ).execute().getAccessToken()
71
76
}
72
77
73
- private def executeManagementApiRequest [T ](req : com.auth0.net.Request [T ]) =
78
+ private def executeManagementApiRequest [T ](
79
+ req : com.auth0.net.Request [T ]
80
+ )(implicit traceContext : TraceContext ) =
74
81
retry.retryAuth0CallsForTests {
75
82
// Auth0 management API calls are rate limited, with limits much lower than
76
83
// the rate limits for the auth API calls.
@@ -85,7 +92,7 @@ class Auth0Util(
85
92
object Auth0Util {
86
93
87
94
trait Auth0Retry {
88
- def retryAuth0CallsForTests [T ](f : => T ): T
95
+ def retryAuth0CallsForTests [T ](f : => T )( implicit traceContext : TraceContext ) : T
89
96
}
90
97
91
98
trait WithAuth0Support {
@@ -115,19 +122,22 @@ object Auth0Util {
115
122
clientSecret,
116
123
loggerFactory,
117
124
new Auth0Retry {
118
- def handleExceptions (e : Throwable ): Nothing = e match {
119
- case auth0Exception : Auth0Exception => {
120
- logger.debug(" Auth0 exception raised, triggering retry..." )
121
- fail(auth0Exception)
122
- }
123
- case ioException : java.io.IOException => {
124
- logger.debug(" IOException raised, triggering retry..." )
125
- fail(ioException)
125
+ def handleExceptions (e : Throwable )(implicit traceContext : TraceContext ): Nothing =
126
+ e match {
127
+ case auth0Exception : Auth0Exception => {
128
+ logger.debug(" Auth0 exception raised, triggering retry..." , auth0Exception)
129
+ fail(auth0Exception)
130
+ }
131
+ case ioException : java.io.IOException => {
132
+ logger.debug(" IOException raised, triggering retry..." , ioException)
133
+ fail(ioException)
134
+ }
135
+ case ex : Throwable => throw ex // throw anything else
126
136
}
127
- case ex : Throwable => throw ex // throw anything else
128
- }
129
137
130
- override def retryAuth0CallsForTests [T ](f : => T ): T = {
138
+ override def retryAuth0CallsForTests [T ](
139
+ f : => T
140
+ )(implicit traceContext : TraceContext ): T = {
131
141
eventually() {
132
142
try {
133
143
f
0 commit comments