Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef REMOTING_PROTOCOL_FAKE_AUTHENTICATOR_H_ | |
| 6 #define REMOTING_PROTOCOL_FAKE_AUTHENTICATOR_H_ | |
| 7 | |
| 8 #include "remoting/protocol/authenticator.h" | |
| 9 #include "remoting/protocol/channel_authenticator.h" | |
| 10 | |
| 11 namespace remoting { | |
| 12 namespace protocol { | |
| 13 | |
| 14 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
| |
| 15 public: | |
| 16 FakeChannelAuthenticator(bool accept); | |
| 17 virtual ~FakeChannelAuthenticator(); | |
| 18 | |
| 19 // ChannelAuthenticator interface. | |
| 20 virtual void SecureAndAuthenticate( | |
| 21 net::StreamSocket* socket, const DoneCallback& done_callback) OVERRIDE; | |
| 22 | |
| 23 private: | |
| 24 bool accept_; | |
| 25 | |
| 26 DISALLOW_COPY_AND_ASSIGN(FakeChannelAuthenticator); | |
| 27 }; | |
| 28 | |
| 29 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
| |
| 30 public: | |
| 31 enum Type { | |
| 32 HOST, | |
| 33 CLIENT, | |
| 34 }; | |
| 35 | |
| 36 enum Action { | |
| 37 ACCEPT, | |
| 38 REJECT, | |
| 39 REJECT_CHANNEL, | |
| 40 }; | |
| 41 | |
| 42 FakeAuthenticator(Type type, Action action, int round_trips); | |
| 43 virtual ~FakeAuthenticator(); | |
| 44 | |
| 45 // Authenticator interface. | |
| 46 virtual State state() const OVERRIDE; | |
| 47 virtual void ProcessMessage(const buzz::XmlElement* message) OVERRIDE; | |
| 48 virtual buzz::XmlElement* GetNextMessage() OVERRIDE; | |
| 49 virtual ChannelAuthenticator* CreateChannelAuthenticator() const OVERRIDE; | |
| 50 | |
| 51 protected: | |
| 52 Type type_; | |
| 53 Action action_; | |
| 54 int round_trips_; | |
| 55 | |
| 56 // Total number of messages that have been processed. | |
| 57 int messages_; | |
| 58 | |
| 59 DISALLOW_COPY_AND_ASSIGN(FakeAuthenticator); | |
| 60 }; | |
| 61 | |
| 62 class FakeHostAuthenticatorFactory : public AuthenticatorFactory { | |
| 63 public: | |
| 64 FakeHostAuthenticatorFactory(FakeAuthenticator::Action action, | |
| 65 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
| |
| 66 virtual ~FakeHostAuthenticatorFactory(); | |
| 67 | |
| 68 // AuthenticatorFactory interface. | |
| 69 virtual Authenticator* CreateAuthenticator( | |
| 70 const std::string& remote_jid, | |
| 71 const buzz::XmlElement* first_message) OVERRIDE; | |
| 72 | |
| 73 private: | |
| 74 FakeAuthenticator::Action action_; | |
| 75 int round_trips_; | |
| 76 | |
| 77 DISALLOW_COPY_AND_ASSIGN(FakeHostAuthenticatorFactory); | |
| 78 }; | |
| 79 | |
| 80 } // namespace protocol | |
| 81 } // namespace remoting | |
| 82 | |
| 83 #endif // REMOTING_PROTOCOL_FAKE_AUTHENTICATOR_H_ | |
| OLD | NEW |