Welcome to mirror list, hosted at ThFree Co, Russian Federation.

NewConnectionWizardBot.java « bots « ui « integration « test « studio « directory « apache « org « java « main « src « test.integration.ui « tests - github.com/apache/directory-studio.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1591c4a644f54500100dc84fe93f81d0feeaaaae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
/*
 *  Licensed to the Apache Software Foundation (ASF) under one
 *  or more contributor license agreements.  See the NOTICE file
 *  distributed with this work for additional information
 *  regarding copyright ownership.  The ASF licenses this file
 *  to you under the Apache License, Version 2.0 (the
 *  "License"); you may not use this file except in compliance
 *  with the License.  You may obtain a copy of the License at
 *  
 *    http://www.apache.org/licenses/LICENSE-2.0
 *  
 *  Unless required by applicable law or agreed to in writing,
 *  software distributed under the License is distributed on an
 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *  KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations
 *  under the License. 
 *  
 */
package org.apache.directory.studio.test.integration.ui.bots;


import org.apache.directory.api.ldap.model.constants.SaslQoP;
import org.apache.directory.api.ldap.model.constants.SaslSecurityStrength;
import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
import org.apache.directory.studio.test.integration.ui.utils.JobWatcher;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;


public class NewConnectionWizardBot extends WizardBot
{

    private static final String TITLE = "New LDAP Connection";
    private static final String CERTIFICATE_TRUST = "Certificate Trust";
    private static final String CONNECTION_NAME = "Connection name:";
    private static final String HOSTNAME = "Hostname:";
    private static final String PORT = "Port:";
    private static final String CHECK_AUTHENTICATION = "Check Authentication";
    private static final String CHECK_NETWORK_PARAMETER = "Check Network Parameter";
    private static final String VIEW_CERTIFICATE = "View Certificate...";
    private static final String BASE_DN = "Base DN:";
    private static final String GET_BASE_DNS_FROM_ROOT_DSE = "Get base DNs from Root DSE";
    private static final String SAVE_PASSWORD = "Save password";
    private static final String SASL_REALM = "SASL Realm:";
    private static final String SASL_QUALITY_OF_PROTECTION = "Quality of Protection:";
    private static final String SASL_PROTECTION_STRENGH = "Protection Strength:";
    private static final String BIND_PASSWORD = "Bind password:";
    private static final String BIND_DN_OR_USER = "Bind DN or user:";
    private static final String CRAM_MD5_SASL = "CRAM-MD5 (SASL)";
    private static final String DIGEST_MD5_SASL = "DIGEST-MD5 (SASL)";
    private static final String GSS_API_SASL = "GSSAPI (Kerberos)";
    private static final String NO_AUTHENTICATION = "No Authentication";
    private static final String SIMPLE_AUTHENTICATION = "Simple Authentication";
    private static final String AUTHENTICATION_METHOD = "Authentication Method";
    private static final String ENCRYPTION_METHOD = "Encryption method:";
    private static final String NO_ENCRYPTION = "No encryption";
    private static final String START_TLS_ENCRYPTION = "Use StartTLS extension";
    private static final String LDAPS_ENCRYPTION = "Use SSL encryption (ldaps://)";
    private static final String USE_NATIVE_TGT = "Use native TGT";
    private static final String OBTAIN_TGT_FROM_KDC = "Obtain TGT from KDC (provide username and password)";
    private static final String USE_NATIVE_SYSTEM_CONFIG = "Use native system configuration";
    private static final String USE_CONFIG_FILE = "Use configuration file:";
    private static final String USE_MANUAL_CONFIG = "Use following configuration:";
    private static final String KERBEROS_REALM = "Kerberos Realm:";
    private static final String KDC_HOST = "KDC Host:";
    private static final String KDC_PORT = "KDC Port:";

    public NewConnectionWizardBot()
    {
        super( TITLE );
    }


    public void clickFinishButton( boolean waitTillConnectionOpened )
    {
        JobWatcher watcher = null;
        if ( waitTillConnectionOpened )
        {
            watcher = new JobWatcher( BrowserCoreMessages.jobs__open_connections_name_1 );
        }
        super.clickFinishButton();
        if ( waitTillConnectionOpened )
        {
            watcher.waitUntilDone();
        }
    }


    public void typeConnectionName( String connectionName )
    {
        SWTBotText connText = bot.textWithLabel( CONNECTION_NAME );
        connText.setText( connectionName );
    }


    public void typeHost( String host )
    {
        SWTBotCombo hostnameCombo = bot.comboBoxWithLabel( HOSTNAME );
        hostnameCombo.setText( host );
    }


    public void typePort( int port )
    {
        SWTBotCombo portCombo = bot.comboBoxWithLabel( PORT );
        portCombo.setText( Integer.toString( port ) );
    }


    public boolean isSimpleAuthenticationSelected()
    {
        SWTBotCombo authMethodCombo = bot.comboBoxInGroup( AUTHENTICATION_METHOD );
        return SIMPLE_AUTHENTICATION.equals( authMethodCombo.selection() );
    }


    public void selectSimpleAuthentication()
    {
        SWTBotCombo authMethodCombo = bot.comboBoxInGroup( AUTHENTICATION_METHOD );
        authMethodCombo.setSelection( SIMPLE_AUTHENTICATION );
    }


    public boolean isNoAuthenticationSelected()
    {
        SWTBotCombo authMethodCombo = bot.comboBoxInGroup( AUTHENTICATION_METHOD );
        return NO_AUTHENTICATION.equals( authMethodCombo.selection() );
    }


    public void selectNoAuthentication()
    {
        SWTBotCombo authMethodCombo = bot.comboBoxInGroup( AUTHENTICATION_METHOD );
        authMethodCombo.setSelection( NO_AUTHENTICATION );
    }


    public boolean isDigestMD5AuthenticationSelected()
    {
        SWTBotCombo authMethodCombo = bot.comboBoxInGroup( AUTHENTICATION_METHOD );
        return DIGEST_MD5_SASL.equals( authMethodCombo.selection() );
    }


    public void selectDigestMD5Authentication()
    {
        SWTBotCombo authMethodCombo = bot.comboBoxInGroup( AUTHENTICATION_METHOD );
        authMethodCombo.setSelection( DIGEST_MD5_SASL );
    }


    public boolean isCramMD5AuthenticationSelected()
    {
        SWTBotCombo authMethodCombo = bot.comboBoxInGroup( AUTHENTICATION_METHOD );
        return CRAM_MD5_SASL.equals( authMethodCombo.selection() );
    }


    public void selectCramMD5Authentication()
    {
        SWTBotCombo authMethodCombo = bot.comboBoxInGroup( AUTHENTICATION_METHOD );
        authMethodCombo.setSelection( CRAM_MD5_SASL );
    }


    public boolean isGssApiAuthenticationSelected()
    {
        SWTBotCombo authMethodCombo = bot.comboBoxInGroup( AUTHENTICATION_METHOD );
        return GSS_API_SASL.equals( authMethodCombo.selection() );
    }


    public void selectGssApiAuthentication()
    {
        SWTBotCombo authMethodCombo = bot.comboBoxInGroup( AUTHENTICATION_METHOD );
        authMethodCombo.setSelection( GSS_API_SASL );
    }


    public boolean isUserEnabled()
    {
        return bot.comboBoxWithLabel( BIND_DN_OR_USER ).isEnabled();
    }


    public void typeUser( String user )
    {
        SWTBotCombo dnCombo = bot.comboBoxWithLabel( BIND_DN_OR_USER );
        dnCombo.setText( user );
    }


    public boolean isPasswordEnabled()
    {
        return bot.textWithLabel( BIND_PASSWORD ).isEnabled();
    }


    public void typePassword( String password )
    {
        SWTBotText passwordText = bot.textWithLabel( BIND_PASSWORD );
        passwordText.setText( password );
    }


    public boolean isRealmEnabled()
    {
        return bot.comboBoxWithLabel( SASL_REALM ).isEnabled();
    }


    public void typeRealm( String realm )
    {
        SWTBotCombo combo = bot.comboBoxWithLabel( SASL_REALM );
        combo.setText( realm );
    }


    public void selectQualityOfProtection( SaslQoP saslQoP )
    {
        SWTBotCombo combo = bot.comboBoxWithLabel( SASL_QUALITY_OF_PROTECTION );
        switch ( saslQoP )
        {
            case AUTH:
                combo.setSelection( 0 );
                break;
            case AUTH_INT:
                combo.setSelection( 1 );
                break;
            case AUTH_CONF:
                combo.setSelection( 2 );
                break;
        }
    }


    public void selectProtectionStrength( SaslSecurityStrength saslSecurityStrength )
    {
        SWTBotCombo combo = bot.comboBoxWithLabel( SASL_PROTECTION_STRENGH );
        switch ( saslSecurityStrength )
        {
            case HIGH:
                combo.setSelection( 0 );
                break;
            case MEDIUM:
                combo.setSelection( 1 );
                break;
            case LOW:
                combo.setSelection( 2 );
                break;
        }
    }


    public boolean isSavePasswordEnabled()
    {
        return bot.checkBox( SAVE_PASSWORD ).isEnabled();
    }


    public boolean isSavePasswordSelected()
    {
        return bot.checkBox( SAVE_PASSWORD ).isChecked();
    }


    public void selectSavePassword()
    {
        bot.checkBox( SAVE_PASSWORD ).select();
    }


    public void deselectSavePassword()
    {
        bot.checkBox( SAVE_PASSWORD ).deselect();
    }


    public boolean isUseNativeTgtSelected()
    {
        return bot.radio( USE_NATIVE_TGT ).isSelected();
    }


    public void selectUseNativeTgt()
    {
        bot.radio( USE_NATIVE_TGT ).click();
    }


    public boolean isObtainTgtFromKdcSelected()
    {
        return bot.radio( OBTAIN_TGT_FROM_KDC ).isSelected();
    }


    public void selectObtainTgtFromKdc()
    {
        bot.radio( OBTAIN_TGT_FROM_KDC ).click();
    }


    public boolean isUseNativeSystemConfigurationSelected()
    {
        return bot.radio( USE_NATIVE_SYSTEM_CONFIG ).isSelected();
    }


    public void selectUseNativeSystemConfiguration()
    {
        bot.radio( USE_NATIVE_SYSTEM_CONFIG ).click();
    }


    public boolean isUseConfigurationFileSelected()
    {
        return bot.radio( USE_CONFIG_FILE ).isSelected();
    }


    public void selectUseConfigurationFile()
    {
        bot.radio( USE_CONFIG_FILE ).click();
    }


    public boolean isUseManualConfigurationSelected()
    {
        return bot.radio( USE_MANUAL_CONFIG ).isSelected();
    }


    public void selectUseManualConfiguration()
    {
        bot.radio( USE_MANUAL_CONFIG ).click();
    }


    public boolean isKerberosRealmEnabled()
    {
        return bot.textWithLabel( KERBEROS_REALM ).isEnabled();
    }


    public void typeKerberosRealm( String realm )
    {
        bot.textWithLabel( KERBEROS_REALM ).setText( realm );
    }


    public boolean isKdcHostEnabled()
    {
        return bot.textWithLabel( KDC_HOST ).isEnabled();
    }


    public void typeKdcHost( String host )
    {
        bot.textWithLabel( KDC_HOST ).setText( host );
    }


    public boolean isKdcPortEnabled()
    {
        return bot.textWithLabel( KDC_PORT ).isEnabled();
    }


    public void typeKdcPort( int port )
    {
        bot.textWithLabel( KDC_PORT ).setText( Integer.toString( port ) );
    }


    public boolean isGetBaseDnsFromRootDseEnabled()
    {
        return bot.checkBox( GET_BASE_DNS_FROM_ROOT_DSE ).isEnabled();
    }


    public boolean isGetBaseDnsFromRootDseSelected()
    {
        return bot.checkBox( GET_BASE_DNS_FROM_ROOT_DSE ).isChecked();
    }


    public void selectGetBaseDnsFromRootDse()
    {
        bot.checkBox( GET_BASE_DNS_FROM_ROOT_DSE ).select();
    }


    public void deselectGetBaseDnsFromRootDse()
    {
        bot.checkBox( GET_BASE_DNS_FROM_ROOT_DSE ).deselect();
    }


    public boolean isBaseDnEnabled()
    {
        return bot.comboBoxWithLabel( BASE_DN ).isEnabled();
    }


    public void typeBaseDn( String baseDn )
    {
        SWTBotCombo dnCombo = bot.comboBoxWithLabel( BASE_DN );
        dnCombo.setText( baseDn );
    }


    public boolean isViewCertificateButtonEnabled()
    {
        return bot.button( VIEW_CERTIFICATE ).isEnabled();
    }


    public CertificateViewerDialogBot clickViewCertificateButton()
    {
        bot.button( VIEW_CERTIFICATE ).click();
        return new CertificateViewerDialogBot();
    }


    public boolean isCheckNetworkParameterButtonEnabled()
    {
        return bot.button( CHECK_NETWORK_PARAMETER ).isEnabled();
    }


    /**
     * Clicks the "check network parameter" button.
     * 
     * @return null if the OK dialog pops up, the error message if the error dialog pops up
     */
    public CheckResponse clickCheckNetworkParameterButton()
    {
        activate();
        return clickCheckButton( CHECK_NETWORK_PARAMETER, CHECK_NETWORK_PARAMETER );
    }


    /**
     * Clicks the "check network parameter" button.
     */
    public CertificateTrustDialogBot clickCheckNetworkParameterButtonExpectingCertificateTrustDialog()
    {
        bot.button( CHECK_NETWORK_PARAMETER ).click();
        bot.shell( CERTIFICATE_TRUST );
        return new CertificateTrustDialogBot();
    }


    /**
     * Clicks the "check authentication" button.
     * 
     * @return null if the OK dialog pops up, the error message if the error dialog pops up
     */
    public String clickCheckAuthenticationButton()
    {
        CheckResponse checkResponse = clickCheckButton( CHECK_AUTHENTICATION, CHECK_AUTHENTICATION );
        return checkResponse.isError() ? checkResponse.getMessage() : null;
    }


    /**
     * Clicks the "check authentication" button.
     */
    public CertificateTrustDialogBot clickCheckAuthenticationButtonExpectingCertificateTrustDialog()
    {
        bot.button( CHECK_AUTHENTICATION ).click();
        bot.shell( CERTIFICATE_TRUST );
        return new CertificateTrustDialogBot();
    }


    public boolean isNoEncryptionSelected()
    {
        SWTBotCombo encMethodCombo = bot.comboBoxWithLabel( ENCRYPTION_METHOD );
        return NO_ENCRYPTION.equals( encMethodCombo.selection() );
    }


    public void selectNoEncryption()
    {
        SWTBotCombo encMethodCombo = bot.comboBoxWithLabel( ENCRYPTION_METHOD );
        encMethodCombo.setSelection( NO_ENCRYPTION );
    }


    public boolean isStartTlsEncryptionSelected()
    {
        SWTBotCombo encMethodCombo = bot.comboBoxWithLabel( ENCRYPTION_METHOD );
        return START_TLS_ENCRYPTION.equals( encMethodCombo.selection() );
    }


    public void selectStartTlsEncryption()
    {
        SWTBotCombo encMethodCombo = bot.comboBoxWithLabel( ENCRYPTION_METHOD );
        encMethodCombo.setSelection( START_TLS_ENCRYPTION );
    }


    public boolean isLdapsEncryptionSelected()
    {
        SWTBotCombo encMethodCombo = bot.comboBoxWithLabel( ENCRYPTION_METHOD );
        return LDAPS_ENCRYPTION.equals( encMethodCombo.selection() );
    }


    public void selectLdapsEncryption()
    {
        SWTBotCombo encMethodCombo = bot.comboBoxWithLabel( ENCRYPTION_METHOD );
        encMethodCombo.setSelection( LDAPS_ENCRYPTION );
    }

}