@@ -15,6 +15,7 @@ import (
15
15
"strings"
16
16
"time"
17
17
18
+ "github.com/cloudflare/cfssl/helpers"
18
19
"github.com/docker/docker/api/types"
19
20
"github.com/docker/docker/api/types/swarm"
20
21
"github.com/docker/docker/integration-cli/checker"
@@ -1221,10 +1222,6 @@ func (s *DockerSwarmSuite) TestSwarmJoinPromoteLocked(c *check.C) {
1221
1222
c .Assert (getNodeStatus (c , d ), checker .Equals , swarm .LocalNodeStateActive )
1222
1223
}
1223
1224
1224
- // get d3's cert
1225
- d3cert , err := ioutil .ReadFile (filepath .Join (d3 .Folder , "root" , "swarm" , "certificates" , "swarm-node.crt" ))
1226
- c .Assert (err , checker .IsNil )
1227
-
1228
1225
// demote manager back to worker - workers are not locked
1229
1226
outs , err = d1 .Cmd ("node" , "demote" , d3 .Info .NodeID )
1230
1227
c .Assert (err , checker .IsNil )
@@ -1237,12 +1234,16 @@ func (s *DockerSwarmSuite) TestSwarmJoinPromoteLocked(c *check.C) {
1237
1234
// is set to autolock)
1238
1235
waitAndAssert (c , defaultReconciliationTimeout , d3 .CheckControlAvailable , checker .False )
1239
1236
waitAndAssert (c , defaultReconciliationTimeout , func (c * check.C ) (interface {}, check.CommentInterface ) {
1240
- cert , err := ioutil .ReadFile (filepath .Join (d3 .Folder , "root" , "swarm" , "certificates" , "swarm-node.crt" ))
1237
+ certBytes , err := ioutil .ReadFile (filepath .Join (d3 .Folder , "root" , "swarm" , "certificates" , "swarm-node.crt" ))
1241
1238
if err != nil {
1242
1239
return "" , check .Commentf ("error: %v" , err )
1243
1240
}
1244
- return string (cert ), check .Commentf ("cert: %v" , string (cert ))
1245
- }, checker .Not (checker .Equals ), string (d3cert ))
1241
+ certs , err := helpers .ParseCertificatesPEM (certBytes )
1242
+ if err == nil && len (certs ) > 0 && len (certs [0 ].Subject .OrganizationalUnit ) > 0 {
1243
+ return certs [0 ].Subject .OrganizationalUnit [0 ], nil
1244
+ }
1245
+ return "" , check .Commentf ("could not get organizational unit from certificate" )
1246
+ }, checker .Equals , "swarm-worker" )
1246
1247
1247
1248
// by now, it should *never* be locked on restart
1248
1249
d3 .Restart (c )
0 commit comments