@@ -128,6 +128,39 @@ func TestScim(t *testing.T) {
128
128
assert .Equal (t , sUser .Emails [0 ].Value , userRes .Users [0 ].Email )
129
129
assert .Equal (t , sUser .UserName , userRes .Users [0 ].Username )
130
130
})
131
+
132
+ t .Run ("DomainStrips" , func (t * testing.T ) {
133
+ t .Parallel ()
134
+
135
+ ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
136
+ defer cancel ()
137
+
138
+ scimAPIKey := []byte ("hi" )
139
+ client := coderdenttest .New (t , & coderdenttest.Options {SCIMAPIKey : scimAPIKey })
140
+ _ = coderdtest .CreateFirstUser (t , client )
141
+ coderdenttest .AddLicense (t , client , coderdenttest.LicenseOptions {
142
+ AccountID : "coolin" ,
143
+ Features : license.Features {
144
+ codersdk .FeatureSCIM : 1 ,
145
+ },
146
+ })
147
+
148
+ sUser := makeScimUser (t )
149
+ sUser .UserName = sUser .UserName + "@coder.com"
150
+ res , err := client .Request (ctx , "POST" , "/scim/v2/Users" , sUser , setScimAuth (scimAPIKey ))
151
+ require .NoError (t , err )
152
+ defer res .Body .Close ()
153
+ assert .Equal (t , http .StatusOK , res .StatusCode )
154
+
155
+ userRes , err := client .Users (ctx , codersdk.UsersRequest {Search : sUser .Emails [0 ].Value })
156
+ require .NoError (t , err )
157
+ require .Len (t , userRes .Users , 1 )
158
+
159
+ assert .Equal (t , sUser .Emails [0 ].Value , userRes .Users [0 ].Email )
160
+ // Username should be the same as the given name. They all use the
161
+ // same string before we modified it above.
162
+ assert .Equal (t , sUser .Name .GivenName , userRes .Users [0 ].Username )
163
+ })
131
164
})
132
165
133
166
t .Run ("patchUser" , func (t * testing.T ) {
0 commit comments