Chromium Code Reviews| Index: remoting/protocol/fake_authenticator.h |
| diff --git a/remoting/protocol/fake_authenticator.h b/remoting/protocol/fake_authenticator.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..90df79d516492a449d5ea2f358955174da50f886 |
| --- /dev/null |
| +++ b/remoting/protocol/fake_authenticator.h |
| @@ -0,0 +1,83 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef REMOTING_PROTOCOL_FAKE_AUTHENTICATOR_H_ |
| +#define REMOTING_PROTOCOL_FAKE_AUTHENTICATOR_H_ |
| + |
| +#include "remoting/protocol/authenticator.h" |
| +#include "remoting/protocol/channel_authenticator.h" |
| + |
| +namespace remoting { |
| +namespace protocol { |
| + |
| +class FakeChannelAuthenticator : public ChannelAuthenticator { |
|
Wez
2011/12/09 23:42:33
nit: This is an implementation detail of FakeAuthe
Sergey Ulanov
2011/12/12 22:52:00
It may be useful in some tests, and I don't think
|
| + public: |
| + FakeChannelAuthenticator(bool accept); |
| + virtual ~FakeChannelAuthenticator(); |
| + |
| + // ChannelAuthenticator interface. |
| + virtual void SecureAndAuthenticate( |
| + net::StreamSocket* socket, const DoneCallback& done_callback) OVERRIDE; |
| + |
| + private: |
| + bool accept_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(FakeChannelAuthenticator); |
| +}; |
| + |
| +class FakeAuthenticator : public Authenticator { |
|
Wez
2011/12/09 23:42:33
nit: This is an implementation detail of FakeAuthe
Sergey Ulanov
2011/12/12 22:52:00
It is not an implementation detail. Tests needs to
|
| + public: |
| + enum Type { |
| + HOST, |
| + CLIENT, |
| + }; |
| + |
| + enum Action { |
| + ACCEPT, |
| + REJECT, |
| + REJECT_CHANNEL, |
| + }; |
| + |
| + FakeAuthenticator(Type type, Action action, int round_trips); |
| + virtual ~FakeAuthenticator(); |
| + |
| + // Authenticator interface. |
| + virtual State state() const OVERRIDE; |
| + virtual void ProcessMessage(const buzz::XmlElement* message) OVERRIDE; |
| + virtual buzz::XmlElement* GetNextMessage() OVERRIDE; |
| + virtual ChannelAuthenticator* CreateChannelAuthenticator() const OVERRIDE; |
| + |
| + protected: |
| + Type type_; |
| + Action action_; |
| + int round_trips_; |
| + |
| + // Total number of messages that have been processed. |
| + int messages_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(FakeAuthenticator); |
| +}; |
| + |
| +class FakeHostAuthenticatorFactory : public AuthenticatorFactory { |
| + public: |
| + FakeHostAuthenticatorFactory(FakeAuthenticator::Action action, |
| + int round_trips); |
|
Wez
2011/12/09 23:42:33
If you replaced |round_trips| with |message_sequen
Sergey Ulanov
2011/12/12 22:52:00
This would simplify implementation of fake authent
Wez
2011/12/13 00:12:38
Not sure what you mean "is not allowed"; the sessi
Wez
2011/12/13 00:12:38
The extra complication to the individual tests is
Sergey Ulanov
2011/12/13 02:31:55
Authenticator state may not be set to MESSAGE_READ
Sergey Ulanov
2011/12/13 02:31:55
I've tried to do it in Patch Set 5. It saves 30 li
|
| + virtual ~FakeHostAuthenticatorFactory(); |
| + |
| + // AuthenticatorFactory interface. |
| + virtual Authenticator* CreateAuthenticator( |
| + const std::string& remote_jid, |
| + const buzz::XmlElement* first_message) OVERRIDE; |
| + |
| + private: |
| + FakeAuthenticator::Action action_; |
| + int round_trips_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(FakeHostAuthenticatorFactory); |
| +}; |
| + |
| +} // namespace protocol |
| +} // namespace remoting |
| + |
| +#endif // REMOTING_PROTOCOL_FAKE_AUTHENTICATOR_H_ |